cop*_*lii 21 android android-studio android-studio-3.2 androidx android-jetifier
我有2个模块的一个项目:一个应用程序(JAVA)与构建类型debug
,release
以及enterprise
和科特林库(release
以及debug
由应用程序使用).
我正在使用AndroidX并且在我的内容中有以下内容gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
如果我通过Gradle运行项目,我会收到一堆编译错误(预期).但是,如果我尝试在Android Studio(3.2 Beta 5)中使用它,特别是在尝试与Gradle模型同步时,我会得到:
Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@enterprise/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Unable to resolve dependency for ':app@enterpriseUnitTest/compileClasspath': Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
Run Code Online (Sandbox Code Playgroud)
我的settings.gradle
:
include ':app',':some-lib'
project(':some-lib').projectDir = file ('../some-lib/lib')
Run Code Online (Sandbox Code Playgroud)
库模块最终将是这个应用程序和其他人使用的自己的库,但是当我正在处理它时,我将它构建为应用程序的一部分.事情进展顺利,直到我切换到AndroidX.
该app
模块将依赖声明为:
implementation project(path: ':some-lib', configuration: 'default')
Run Code Online (Sandbox Code Playgroud)
如果我configuration: 'default'
在声明依赖项时遗漏了这一点,我得到:
Unable to resolve dependency for ':app@enterprise/compileClasspath': Could not resolve project :some-lib.
Unable to resolve dependency for ':app@enterpriseUnitTest/compileClasspath': Could not resolve project :some-lib.
Run Code Online (Sandbox Code Playgroud)
关于我在这里做错了什么的想法?
Dav*_*son 11
该错误似乎是由损坏的 Jetified 文件引起的。
仅从 Gradle 缓存文件夹中删除损坏的 .aar:
rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar
Run Code Online (Sandbox Code Playgroud)
“路径”可能是包名,例如, com.example.somerelease
有时可以从错误消息本身中获取要删除的文件的路径,并将其剪切并粘贴到终端中以执行rm
命令。
删除整个文件夹不是最佳解决方案,因为所有依赖项都需要再次 Jetified。如果您已经遇到损坏问题,您很可能会再次遇到该问题。
我可以发誓我已经尝试过了,但是matchingFallbacks
为构建类型指定一组确实可以解决问题:
buildTypes {
release {
// blah blah
matchingFallbacks = ['release']
}
enterprise {
// blah blah
matchingFallbacks = ['release']
}
debug {
// blah blah
matchingFallbacks = ['debug']
}
}
Run Code Online (Sandbox Code Playgroud)
这里更多
归档时间: |
|
查看次数: |
10043 次 |
最近记录: |