Gradle 依赖导入报错:

错误提示:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':libraries/zxing'.
> The project name 'libraries/zxing' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/5.4.1/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 5s

** 1, 需要修改项:**

project/app/build.gradle:

	//修改:
    implementation project(':libraries/zxing')
	//为:
    implementation project(':zxing')

project/setting.gradle:

	//修改:
	include ':libraries/zxing'
	//为:
	include 'zxing'
	project(':zxing').projectDir =file('libraries/zxing')

2,gradle 引入方法:

通常在一个app项目中引入另一个android library有三种方法:
1.直接拷贝aar包到app的libs目录下,然后在app module的build.gradle加入compile(name:‘your module file name’,ext:‘aar’)就ok了
这种方式不能或者说很难debug到模块的源代码里,但对于稳定的模块,推荐这样做
注:还需要在build.gradle的

android{
    
    
    repositories {
    
    
        flatDir {
    
    
            dirs 'libs'
         }
   }
}

2.import module

这种方式是把模块的源代码直接拷贝到该app下了,自然可以debug,但如果有多个项目这样引用的话,代码更新不好管理.

3.在setting.gradle中配置另一个module的路径,比如我的配置:

include ‘rechatlib’
project(’:rechatlib’).projectDir =file(’…/ChatLib/rechatlib’)

然后在app module的build.gradle中引用:
implementation project(’:rechatlib’)。

猜你喜欢

转载自blog.csdn.net/u013233097/article/details/101349896
今日推荐