'How to know if a support library already supports AndroidX?
I have project in unity, that uses Mapbox,
Mapbox includes the following support library: support-v4-25.1.0.aar
This library comes as an .aar file and NOT as a gradle implementation command
When trying to build the project i get this error:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
Could not resolve all artifacts for configuration ':launcher:debugRuntimeClasspath'.
Failed to transform support-v4-25.1.0-.aar (:support-v4-25.1.0:) to match attributes {artifactType=android-manifest, org.gradle.status=integration}.
> Execution failed for JetifyTransform:
C:\Users\EFGH\Documents\GitHub\AREX\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar.
> Failed to transform 'C:\Users\EFGH\Documents\GitHub\AREX\Temp\gradleOut\unityLibrary\libs\support-v4-25.1.0.aar' using Jetifier.
Reason: AmbiguousStringJetifierException, message: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
This is a known exception, and Jetifier won't be able to jetify this library. Suggestions:
- If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support libraries/AndroidX at all), add android.jetifier.blacklist = {comma-separated list of regular expressions (or simply names) of the libraries that you don't want to be jetified} to the gradle.properties file.
- If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't jetified), contact the library's authors to update this library to support AndroidX and use the supported version once it is released.
If you need further help, please leave a comment at https://issuetracker.google.com/issues/140747218.
My gradle.properties:
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
**ADDITIONAL_PROPERTIES**
I would like to know if there is a way for me to know if a specific support library already have support for AndroidX?(So it won't need to be jetified)
Furthermore to begin with: why does some libraries don't need to be jetified? What is the meaning of when a support library have support for AndroidX and don't need to be jetified? Isn't jetify the act of automatically replacing support libraries with their corresponding AndroidX equivalent libs? How can a support library even get a free pass from being jetified? It doesn't make sense to me at all..
Solution 1:[1]
Pretty sure it's describing rare possibilities where you wouldn't need to use jetify it, for example, if it's being done in a class that doesn't use it, or in a class that is never used. It's very unlikely that this is the case unless the library designer was very sloppy. But possibly, it might also be OK if it is only using the support library in a class that your app will never touch. Not sure if it would be able to compile if you black list it in that condition.
Most likely you are out of luck until you can get the library author to fix it, or you could fork their library and fix it in your own copy if it's open source. Jetpack has been around for several years now. Any library still using the old support library has a high likelihood that it has been abandoned for years, so that is also something to consider.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tenfour04 |
