John O'Reilly
John O'Reilly

Reputation: 10330

'Failed to transform" error after migrating to AndroidX

I'm using Android Studio 3.2 Canary 14 and am trying to migrate an existing project to use AndroidX. It sounds from https://developer.android.com/topic/libraries/support-library/androidx-rn that I have to have set android.enableJetifier=true (this was done automatically for me when selecting "Refactor to AndroidX.." option). I've also updated target API level to 28. Anyone else seeing this issue?

Failed to transform '/Users/jooreill/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-perf/15.0.0/6e68f6e44b0c9d91756f903547ee3853349ae666/firebase-perf-15.0.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.

The above error occurs when I run "Clean". In general am getting multiple errors like following if a do gradle sync:

Unable to resolve dependency for ':app-instant@debug/compileClasspath': Failed to transform file 'play-services-measurement-base-15.0.2.aar' to match attributes {artifactType=jetified-aar} using transform JetifyTransform

Upvotes: 15

Views: 28968

Answers (5)

Maragues
Maragues

Reputation: 38324

I had this same error after adding JDK 11 to my machine. It set itself as default JDK and this error started happening.

After setting JDK 8 as default, it was fixed.

Upvotes: 1

irgendwr
irgendwr

Reputation: 607

For those experiencing the same issue with Android Studio 3.2 Canary 15 (or later) after using "Refactor to AndroidX...":

I had to update some dependencies manually, i.e. change

    classpath 'io.fabric.tools:gradle:1.25.1'

to

    classpath 'io.fabric.tools:gradle:1.27.0'

in my project's build.gradle file.

If you're using dagger you have to upgrade to version 2.20 or later.

This is because some libraries are not yet compatible with the AndroidX refactor as mentioned under Known issues in the AndroidX release notes.

Upvotes: 8

Mikael
Mikael

Reputation: 304

I was able to work around a similar problem by excluding a certain library from being jetified, which can be done by adding to gradle.properties:

android.jetifier.blacklist = ...

Note that this option was added in Android Gradle plugin 3.3.0-rc01 as a temporary workaround. See https://issuetracker.google.com/issues/119135578#comment5 for more details.

Upvotes: 7

stan
stan

Reputation: 71

I had been experiencing this problem while running assembleAndroidTest on Jenkins. The weirdest part was that this task ran sans any issues on my mac's terminal without any issues, but failed on Jenkins with-

Failed to transform file 'cucumber-java-1.2.5.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform

Had been looking for solutions for a couple of days now, having worked though different suggestions - none of which worked.

Finally, disabling Jetifier in gradle.properties resolved it for me.

android.enableJetifier=false

Upvotes: 7

Julian Os
Julian Os

Reputation: 281

As per a statement on the AndroidX refactor made by a Google Engineer (Support Library) during the I/O session "What's New in Support Library?", Google already discovered bugs related to Jetifier in Android Studio 3.2 Canary 14.

Thus, it is advised to wait until Canary 15 (to be released the coming week) before starting the AndroidX migration process.

Upvotes: 3

Related Questions