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’)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章