Search code examples
androidandroid-studioandroid-gradle-plugin

'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


Solution

  • 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.