Running Android Studio 3.2 with the following settings in my gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
I have a native project with some C/Java code. With these settings, the compilation fails with the following error message:
org.gradle.api.artifacts.transform.ArtifactTransformException: Failed to transform file 'android.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
java.lang.RuntimeException: Failed to transform 'C:\Android\sdk\platforms\android-28\android.jar' using Jetifier.
I believe it doesn't like my gradle file:
apply plugin: 'java'
...
dependencies {
implementation files("${mySdkDir}/android.jar")
}
I know I can globally turn off enableJetifier
which would indeed make this error go away. However, I only want to disable the jetifier for this specific module/dependency.
How do I set enableJetifier=false
for a native/java module project?
You need to verify that your own code and all your dependencies (including transitives) are not support-library-dependent any more. it means that you achieved that. Now you can remove the android. enableJetifier flag from your gradle.
android. enableJetifier=true. The Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. Note: The built-in Android Studio migration might not handle everything.
Note: With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components. You can continue to use the support library.
The question probably isn't how to disable the Jetifier for the module -
because this is coming from using the wrong plugin for the module.
apply plugin: "com.android.application"
// apply plugin: "com.android.library"
android {
...
}
There is no way to disable the Jetifier for a module, because it is a project-wide feature... and so the only way around this is not to have android.jar
being explicitly listed in the dependencies
block. It's not even meant to be packaged, therefore it has lost nothing in there - and it's not meant to be processed by the Jetifier, which merely is the result of having it declared as a dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With