androidX jetifier - Is there a way to ignore jetifying a .JAR?
Asked Answered
B

4

17

Trying to update my app to androidX dependencies. Followed instructions here, and compilation failed. The error came from JetifyTransform task failing to process a certain .JAR dependency (FYI - Samsungs Spass SDK) :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptGenerateStubsStandardNo_vendorDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:standardNo_vendorDebugCompileClasspath'.
   > Failed to transform file 'pass-v1.2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
      > Failed to transform '/Users/hanandann/StudioProjects/ArnakPaymentsAndroid/Payments/app/libs/pass-v1.2.2.jar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)
   > Failed to transform file 'pass-v1.2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
      > Failed to transform '/Users/hanandann/StudioProjects/ArnakPaymentsAndroid/Payments/app/libs/pass-v1.2.2.jar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)

Trying to jetify with jetifier-standalone tool had similar results:

Hanans-MacBook-Pro:bin hanandann$ ./jetifier-standalone -i /Users/hanandann/StudioProjects/.../app/libs/pass-v1.2.2.jar -o /Users/hanandann/StudioProjects/.../app/libs/pass-v1.2.2jet.jar 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8
    at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2313)
    at org.objectweb.asm.ClassReader.readFrame(ClassReader.java:2269)
    at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1448)
    at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:39)
    at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:443)
    at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:49)
    at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:425)
    at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:76)
    at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:421)
    at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:247)
    at com.android.tools.build.jetifier.processor.Processor.transform$default(Processor.kt:234)
    at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:157)
    at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:109)
    at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)

Now, I don't really mind if SDK's don't get jetified, so I tried setting android.enableJetifier=false in my gradle.properties file, but compilation failed again for a different reason- SupportMapFragment isn't compatible with androidX yet as is reported here

So I'm stuck. With jetify the .JAR won't transform. with it - SupportMapFarg is incompatible.

Any suggestions?

P.S. you know what would be nice? if there was an ignore option for the jetifying function

Blastoff answered 23/4, 2019 at 14:50 Comment(1)
I got same error because some lib jar file was "malformed" or something, which was a deprecation warning in Gradle 4 and a fatal error in Gradle 5. Downgrading to Gradle 4 solved the issue.Amylose
B
23

added this to gradle.properties:

android.jetifier.blacklist = pass

as suggested by folks at google here.

Be warned - this feature is experimental and unsupported.


Update- current syntax is android.jetifier.ignorelist={your.ignored.lib} as Suggested by @YaMiN

Blastoff answered 26/4, 2019 at 8:6 Comment(3)
This works for me and says "WARNING: The option setting 'android.jetifier.blacklist=pass' is experimental and unsupported.". Thanks.Clammy
This does absolutely nothing.Stripe
Any equivalent options for Xamarin android?Unbiased
B
10

Currently android.jetifier.blacklist is deprecated.

It was removed in version 7.0 of the Android Gradle plugin. This property has been replaced by android.jetifier.ignorelist

Bashibazouk answered 14/1, 2022 at 22:49 Comment(0)
N
5

Add this in project's gradle.properties: android.jetifier.blacklist =xx.aar,yy.jar split the black list with comma

update on 2022/06/07

If you use gradle 7, it change to android.jetifier.ignorelist

Nares answered 20/5, 2021 at 9:53 Comment(0)
A
2

If you need to ignore just a specific .jar file from the jetifier. You can add the file name in the gradle.properties like on the last line from this example.

android.useAndroidX=true
android.enableJetifier=true
android.jetifier.blacklist=liblinphone-4.0.1-debug-symbols.jar
Ambrosial answered 12/1, 2021 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.