我有一个包含2个模块的项目:构建类型为debug
,release
和enterprise
的应用(Java)和Kotlin库(release
和{{ 1}})。
我正在使用AndroidX,并且在我的debug
中包含以下内容:
gradle.properties
如果我通过Gradle运行项目,则会遇到一堆编译错误(预期)。但是,如果我尝试从Android Studio(3.2 Beta 5)中使用它,特别是在尝试与Gradle模型同步时,我会得到:
android.useAndroidX=true
android.enableJetifier=true
我的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
:
settings.gradle
该库模块最终将是该应用程序和其他应用程序使用的自己的库,但是当我在使用它时,我将其构建为该应用程序的一部分。一切正常,直到我切换到AndroidX。
include ':app',':some-lib'
project(':some-lib').projectDir = file ('../some-lib/lib')
模块将依赖项声明为:
app
如果在声明依赖项时忽略了implementation project(path: ':some-lib', configuration: 'default')
位,则会得到:
configuration: 'default'
对我在这里做错的任何想法吗?
答案 0 :(得分:4)
我可以发誓我已经尝试过此方法,但是为构建类型指定一组matchingFallbacks
可以达到目的:
buildTypes {
release {
// blah blah
matchingFallbacks = ['release']
}
enterprise {
// blah blah
matchingFallbacks = ['release']
}
debug {
// blah blah
matchingFallbacks = ['debug']
}
}
更多here
答案 1 :(得分:1)
尝试一下:
implementation fileTree(include:[':some-lib'], dir: "../lib/path")
答案 2 :(得分:1)
我找到了解决方案。只需在build.gradle(app)中输入以下几行
Category: Software
Lifecycle: Keep logs after terminating environment
Environment properties: GRADLE_HOME, JAVA_HOME, M2, M2_HOME, SERVER_PORT
Rotate logs: disabled
Retention: 1 days
Log streaming: enabled
X-Ray daemon: disabled
Category: Instances
AMI ID: XXXXXXXXXXXXXXXXXXXXXXXXX
Instance type: t3.micro
Monitoring interval: 5 minute
IOPS: container default
Size: container default
Root volume type: container default
EC2 security groups: XXXXXXXXXXXXXXXXXXXXXXXXX
Category: Security
IAM instance profile: XXXXXXXXXXXXXXXXXXXXXXXXX
EC2 key pair: XXXXXXXXXXXXXXXXXXXXXXXXX
Service role: XXXXXXXXXXXXXXXXXXXXXXXXX
Category: Network
Public IP address: disabled
Instance subnets: mysubnet-XXXXXX
Visibility: public
VPC: vpc-XXXXXXX
答案 3 :(得分:1)
解决此问题的选项(明智的优先选择):
(注意:仅当上一个选项不起作用时,请遵循下一个)
implementation project(path: ':yourLibraryname', configuration: 'default')
Invalidate Caches/Restart
。答案 4 :(得分:0)
该错误似乎是由损坏的Jetified文件引起的。
仅从Gradle缓存文件夹中删除损坏的.jar:
rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar
“路径”可能是软件包名称,例如com.example.somerelease
删除整个文件夹不是最佳解决方案,因为所有依赖项都需要再次进行Jetify。如果您已经有 腐败问题,您很可能会再次遇到该问题。
答案 5 :(得分:0)
我今天也遇到了这样的问题,希望我能解决。 在我的情况下,.aar文件的名称为“ open-web-sdk-release.aar”。
错误在这里implementation files("libs/open-web-sdk-release")
。
我将其替换为implementation project(":open-web-sdk-release")
。
使用了此链接... https://developer.android.com/studio/build#module-level。