Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

android - Failed to transform file 'some-lib-release.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform

I have a project with 2 modules: an app (Java) with build types debug, release, and enterprise and a Kotlin library (release and debug) used by the app.

I'm using AndroidX and have the following in my gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

If I run the project through Gradle, I get a bunch of compile errors (expected). But if I try to use it from within Android Studio (3.2 Beta 5), specifically when trying to sync with the Gradle model, I get this:

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

My settings.gradle:

include ':app',':some-lib'
project(':some-lib').projectDir = file ('../some-lib/lib')

The library module will eventually be its own library used by this app and others, but while I'm working on it I build it as a part of the app. Things were working fine until I switched to AndroidX.

The app module declares the dependency as:

implementation project(path: ':some-lib', configuration: 'default')

If I leave out the configuration: 'default' bit when declaring the dependency, I get:

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.

Any ideas on what I'm doing wrong here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error seems to be caused by corrupt Jetified files.

Delete ONLY the corrupted .aar from the Gradle caches folder:

rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar

The "path-to" will be probably be the package name e.g., com.example.somerelease

Sometimes it is possible to get the path of the file to delete from the error message itself and cut and paste it into the terminal in order to execute the rm command.

Deleting the entire folder is not an optimal solution as all the dependencies will need to be Jetified again. If you're already having corruption issues, you're likely to encounter the issue again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...