Fixed
Status Update
Comments
xa...@google.com <xa...@google.com> #2
I don't think #1 makes a lot of sense. There are already potentially libraries out there without that metadata.
#2 makes the most sense to me, but in case we cannot be 100% reliable we should allow blacklisting libraries as described in #3. This should probably be handled globally for a project (in gradle.properpies rather than in the DSL)
#2 makes the most sense to me, but in case we cannot be 100% reliable we should allow blacklisting libraries as described in #3. This should probably be handled globally for a project (in gradle.properpies rather than in the DSL)
pa...@google.com <pa...@google.com> #3
As I have mentioned I don't think there is a silver bullet. #2 does not work on 100% and #1 will take time before devs will provide the metadata. #3 is in my opinion very important to introduce asap, as the developers have no way how to workaround it at this stage. Also in the future there can be any other issue and there is nothing wrong in doing #3 until we figure out something robust (or for instance finally migrate work manager and navigation to androidx that would make #2 a feasible solution).
hu...@google.com <hu...@google.com> #4
Yes, I'm working on #3 right now to unblock users. We can continue thinking about #2.
hu...@google.com <hu...@google.com> #5
Starting with AGP 3.3.0-rc01 and 3.4.0-alpha04, to blacklist libraries that should not be jetified, users can add a comma-separated list of regular expressions to the following property in the gradle.properties file:
android.jetifier.blacklist = ...
If a library's absolute path contains a substring that matches one of the regular expressions, the library won't be jetified.
For example, if the property is
android.jetifier.blacklist = doNot.*\\.jar, foo
then "/path/to/doNotJetify.jar" won't be jetified.
Change-Id: I6531fe0faafa45dc2811c5223ba199ccce5fee53
Note that this is only a temporary workaround while we work on a proper solution.
android.jetifier.blacklist = ...
If a library's absolute path contains a substring that matches one of the regular expressions, the library won't be jetified.
For example, if the property is
android.jetifier.blacklist = doNot.*\\.jar, foo
then "/path/to/doNotJetify.jar" won't be jetified.
Change-Id: I6531fe0faafa45dc2811c5223ba199ccce5fee53
Note that this is only a temporary workaround while we work on a proper solution.
[Deleted User] <[Deleted User]> #6
Hi. I'm trying to use the `android.jetifier.blacklist` workaround to prevent jetify from processing lombok (which generates a DuplicateEntry exception when trying to transform). I can't see to get it working though. Here are the relevant files:
gradle.properties:
```
android.enableJetifier=true
android.jetifier.blacklist = .*lombok.*
android.useAndroidX=true
```
build.gradle:
```
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
classpath 'com.android.tools.build:gradle:3.3.0-beta03'
}
}
plugins {
id 'com.android.application' //version '3.3.0-beta03'
id 'jacoco'
}
```
gradle.properties:
```
android.enableJetifier=true
android.jetifier.blacklist = .*lombok.*
android.useAndroidX=true
```
build.gradle:
```
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
classpath 'com.android.tools.build:gradle:3.3.0-beta03'
}
}
plugins {
id 'com.android.application' //version '3.3.0-beta03'
id 'jacoco'
}
```
hu...@google.com <hu...@google.com> #7
As mentioned at comment #5 , you will need to use AGP 3.3.0-rc01+ or 3.4.0-alpha04+ for the workaround to take effect.
jt...@temp.thunderhead.com <jt...@temp.thunderhead.com> #8
I am interested in the ability to blacklist dependencies from being jettified as well. The binary rewrite messes with AspectJ aspect classes. It re-introduces this problem: https://issuetracker.google.com/issues/119153999
ms...@gmail.com <ms...@gmail.com> #9
I've succesfully tested the blacklist config with:
* AGP 3.3.0-rc01
* Gradle 5.1-rc-1
I just wanted to add a comment about what I had to blacklist, so that perhaps jetifier can handle this automatically without a rule.
TL;DR: jetifier should probably not even try to open *.so files.
Details:
My project depends (transitively) on a jar which contains only native *.so files.
On one particular machine (docker container) with apparently not enough memory, I was getting this error:
Execution failed for task ':libon-lite-client:checkDebugClasspath'.
> Could not resolve all files for configuration ':libon-lite-client:debugCompileClasspath'.
> Failed to transform artifact 'liblinphone-debug-symbols.jar (org.liblinphone:liblinphone:4.0.1)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}
> Execution failed for JetifyTransform: /root/.gradle/caches/modules-2/files-2.1/org.liblinphone/liblinphone/4.0.1/871c6e76e93a7fa1bbafb5eb450e45c2330e866/liblinphone-4.0.1-debug-symbols.jar.
> Java heap space
(Note that with gradle 4.10.2/AGP 3.2.1, I didn't have this detailed info, but just simply "Transformation hasn’t been executed yet" (https://issuetracker.google.com/issues/119951660 ). I got this additional error message with gradle 5.1-rc-1/AGP 3.2.1.)
Now with gradle 5.1-rc1/AGP-3.3.0-rc01, I have this rule:
android.jetifier.blacklist=liblinphone-4.0.1-debug-symbols.jar
And I no longer get the error.
I suppose jetifier shouldn't even try to look into binary *.so files.
* AGP 3.3.0-rc01
* Gradle 5.1-rc-1
I just wanted to add a comment about what I had to blacklist, so that perhaps jetifier can handle this automatically without a rule.
TL;DR: jetifier should probably not even try to open *.so files.
Details:
My project depends (transitively) on a jar which contains only native *.so files.
On one particular machine (docker container) with apparently not enough memory, I was getting this error:
Execution failed for task ':libon-lite-client:checkDebugClasspath'.
> Could not resolve all files for configuration ':libon-lite-client:debugCompileClasspath'.
> Failed to transform artifact 'liblinphone-debug-symbols.jar (org.liblinphone:liblinphone:4.0.1)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}
> Execution failed for JetifyTransform: /root/.gradle/caches/modules-2/files-2.1/org.liblinphone/liblinphone/4.0.1/871c6e76e93a7fa1bbafb5eb450e45c2330e866/liblinphone-4.0.1-debug-symbols.jar.
> Java heap space
(Note that with gradle 4.10.2/AGP 3.2.1, I didn't have this detailed info, but just simply "Transformation hasn’t been executed yet" (
Now with gradle 5.1-rc1/AGP-3.3.0-rc01, I have this rule:
android.jetifier.blacklist=liblinphone-4.0.1-debug-symbols.jar
And I no longer get the error.
I suppose jetifier shouldn't even try to look into binary *.so files.
hu...@google.com <hu...@google.com> #11
@Filip: I wonder if Jetifier should check the zip entries' meta data first (without loading their contents) and return immediately if there are no entries that need jetifying. (Returning is good enough, Jetifier doesn't need to copy the file to somewhere else. And even when it needs to copy some large entries from one zip file to another, we can probably use streams/Zip64 so that it doesn't load the entire zip file/zip entry into memory---see Issue 113559507 .)
st...@gmail.com <st...@gmail.com> #12
Is anyone else having issues with AGP 3.3.0-rc01+ or 3.4.0-alpha04+ where the project compiles and runs fine, but cannot resolve the R file? I tried invalidating android studio caches, cleaning, deleting .idea, deleting .gradle, and nothing works except reverting to android plugin 3.2.1...which I can't do because I need the jetifier blacklist workaround.
im...@google.com <im...@google.com> #13
@12 Sounds like a different issue, possibly around light R classes handling in the IDE, would you mind filing a bug for it and describing the problem in more detail or provide a repro project?
st...@gmail.com <st...@gmail.com> #14
It seems to be working fine in Android Studio 3.3 so I think it might not be an issue in the future. Thanks for the response!
jt...@temp.thunderhead.com <jt...@temp.thunderhead.com> #15
Hi I was wondering the status of the blacklist? Is this official or on the roadmap for 3.4?
hu...@google.com <hu...@google.com> #16
@15: The android.jetifier.blacklist property is available to use on AGP 3.3.0 and above. However, please note that it is only a workaround.
We are working a on better solution that does not require developers to use the workaround. This bug is left open to keep track of that work.
We are working a on better solution that does not require developers to use the workaround. This bug is left open to keep track of that work.
ne...@gmail.com <ne...@gmail.com> #17
Hi. could you backport blacklist option to 3.2.x release?
hu...@google.com <hu...@google.com> #18
Since the blacklist property is already available on 3.3.0 stable, I'm afraid that we won't be releasing 3.2.2 only to include that. I would recommend updating to 3.3.0 stable instead, and file a bug with us if you think something is blocking you from updating.
ne...@gmail.com <ne...@gmail.com> #19
I have some gradle plugin that doesn't work with 3.3.0.
The problem is that Robolectric can't be used with 3.2.1 when Jetifier is enabled because it tries to re-write 'org.ow2.asm:asm' jar which has class files of version > 52.
So I would like to blacklist this jar from being processed.
The problem is that Robolectric can't be used with 3.2.1 when Jetifier is enabled because it tries to re-write 'org.ow2.asm:asm' jar which has class files of version > 52.
So I would like to blacklist this jar from being processed.
hu...@google.com <hu...@google.com> #20
I see, but again I'm afraid it is too late for 3.2 at this point. One thing you could try is to disable Jetifier (set android.enableJetifier=false), and run the Jetifier standalone tool (https://developer.android.com/studio/command-line/jetifier ) on individual libraries and import the jetified ones instead of the original ones. I know it's not pretty, but hopefully it will work for you.
ri...@gmail.com <ri...@gmail.com> #21
Any ideas about this one -
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptGenerateStubsDebugKotlin'
...
Caused by: java.lang.RuntimeException: Failed to transform '/Users/user/.gradle/caches/modules-2/files-2.1/org.xerial/sqlite-jdbc/3.20.1/df3068e837e9490a9554212fcab40a2c55faf0a3/sqlite-jdbc-3.20.1.jar' using Jetifier. Reason: invalid entry size (expected 618164 but got 636977 bytes). (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:204)
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptGenerateStubsDebugKotlin'
...
Caused by: java.lang.RuntimeException: Failed to transform '/Users/user/.gradle/caches/modules-2/files-2.1/org.xerial/sqlite-jdbc/3.20.1/df3068e837e9490a9554212fcab40a2c55faf0a3/sqlite-jdbc-3.20.1.jar' using Jetifier. Reason: invalid entry size (expected 618164 but got 636977 bytes). (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:204)
hu...@google.com <hu...@google.com> #22
Can you please file a new bug with us and link it here so I can follow up?
ri...@gmail.com <ri...@gmail.com> #23
Sure
ri...@gmail.com <ri...@gmail.com> #24
Hey, deleting and cloning the repo again fixes this issue, do you still want me to file this?
hu...@google.com <hu...@google.com> #25
No need for now (as there is too little information for it to be actionable), but we'll keep that in mind and please do file a bug if you see it again. Thanks!
em...@gmail.com <em...@gmail.com> #26
Hi,
I have this error but I cannot fix if with blacklist, is it the same issue ? Could `android.jetifier.blacklist` property fix it ?
09:08:56 > Could not resolve all files for configuration ':app:releaseUnitTestCompileClasspath'.
09:08:56 > Failed to transform artifact 'full.jar (project :api)' to match attributes {artifactType=processed-jar, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.api.attributes.VariantAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
Thanks
I have this error but I cannot fix if with blacklist, is it the same issue ? Could `android.jetifier.blacklist` property fix it ?
09:08:56 > Could not resolve all files for configuration ':app:releaseUnitTestCompileClasspath'.
09:08:56 > Failed to transform artifact 'full.jar (project :api)' to match attributes {artifactType=processed-jar, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.api.attributes.VariantAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
Thanks
hu...@google.com <hu...@google.com> #27
This is a different issue. Please file a new bug and let me know the bug ID. Thanks!
me...@thomaskeller.biz <me...@thomaskeller.biz> #29
Jetifier really brings up some headaches. We upgraded AGP from 3.5.2 to 3.6.0-beta04 and found our Cucumber tests failing afterwards. The issue Cucumber reports was
cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
Cucumber reports that when an artifact like `cucumber-java` (or any other language backend) is not present. Cucumber tries to service-load this automatically when present in the classpath (seehttps://github.com/cucumber/cucumber-jvm/search?q=JavaBackendProviderService&unscoped_q=JavaBackendProviderService for references), but apparently fails.
Interestingly, the tests continued to run without issues in Android Studio, they were just failing when executed from command line. A test run with --debug showed me that the Gradle run however used jetified versions of the cucumber libraries in the application classpath. Adding `.*cucumber.*` to the jetifier blacklist solved the issue.
I'm completely unaware of the black magic that Jetifier involves, but I see that it has some very serious consequences when applied broadly on a project, things that are rather hard to track down because subtle things like service locators suddenly stop working.
cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
Cucumber reports that when an artifact like `cucumber-java` (or any other language backend) is not present. Cucumber tries to service-load this automatically when present in the classpath (see
Interestingly, the tests continued to run without issues in Android Studio, they were just failing when executed from command line. A test run with --debug showed me that the Gradle run however used jetified versions of the cucumber libraries in the application classpath. Adding `.*cucumber.*` to the jetifier blacklist solved the issue.
I'm completely unaware of the black magic that Jetifier involves, but I see that it has some very serious consequences when applied broadly on a project, things that are rather hard to track down because subtle things like service locators suddenly stop working.
hu...@google.com <hu...@google.com> #30
Thank you for the feedback! We are looking to remove edge cases like this one, and bug reports like this help us do that.
If possible, could you attach the original version of the cucumber library and the jetified version, so that we can investigate what was actually modified by Jetifier?
If possible, could you attach the original version of the cucumber library and the jetified version, so that we can investigate what was actually modified by Jetifier?
hu...@google.com <hu...@google.com> #31
Starting with AGP 4.0.0-alpha07 (using Jetifier 1.0.0-beta06+), Jetifier will not jetify libraries that already support AndroidX: https://android-review.googlesource.com/c/platform/frameworks/support/+/952620/ . The blacklist workaround shouldn't be needed anymore.
After updating to AGP 4.0.0-alpha07+, please remove the android.jetifier.blacklist property if you have been using it. And if you still run into issues after doing that, please file a bug with us athttp://issuetracker.google.com/issues/new?component=460323 .
To close the loop on the 3 different approaches outlined at comment #1 :
> We need a way to determine whether a third-party library should be jetified or not. There are a couple of approaches:
> 1. The library adds some metadata stating that it is AndroidX-ready and therefore should not be jetified.
=> Infeasible
> 2. Jetifier automatically detects the presence of AndroidX (e.g., import statements and strings containing references to AndroidX), and if AndroidX is present, assumes that the library is AndroidX-ready and skips converting it.
=> Implemented
> 3. The users need to specify a blacklist of libraries that should not be jetified.
=> Used previously as a workaround (see comment #5 ), but not recommended now, as approach #2 should remove the need for this workaround. If you still find yourself having to use the blacklist, it is most likely a bug, please tell us at http://issuetracker.google.com/issues/new?component=460323 .
After updating to AGP 4.0.0-alpha07+, please remove the android.jetifier.blacklist property if you have been using it. And if you still run into issues after doing that, please file a bug with us at
To close the loop on the 3 different approaches outlined at
> We need a way to determine whether a third-party library should be jetified or not. There are a couple of approaches:
> 1. The library adds some metadata stating that it is AndroidX-ready and therefore should not be jetified.
=> Infeasible
> 2. Jetifier automatically detects the presence of AndroidX (e.g., import statements and strings containing references to AndroidX), and if AndroidX is present, assumes that the library is AndroidX-ready and skips converting it.
=> Implemented
> 3. The users need to specify a blacklist of libraries that should not be jetified.
=> Used previously as a workaround (see
Description
Example failures:
(1)
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Failed to transform file 'butterknife-compiler-9.0.0-SNAPSHOT.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform '...\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife-compiler\9.0.0-SNAPSHOT\d5efd0795737d4523044335a7faa82b0e3d984c9\butterknife-compiler-9.0.0-SNAPSHOT.jar' using Jetifier.
Reason: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
(2)
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Failed to transform file 'jetifier-core-1.0.0-alpha10.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform '/Users/nkotula/.gradle/caches/modules-2/files-2.1/com.android.tools.build.jetifier/jetifier-core/1.0.0-alpha10/9eb7027c383061de12f93aae7a22cbeb97832d2a/jetifier-core-1.0.0-alpha10.jar' using Jetifier. Reason: 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.
(In this example, Jetifier even tries to jetify itself!)
(3)
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Failed to transform file 'kotlin-compiler-embeddable-1.2.21.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform '/root/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.2.21/39456b64a42dc359e385697e2e93b5cba52e197f/kotlin-compiler-embeddable-1.2.21.jar' using Jetifier.
Reason: Malformed input or input contains unmappable characters: javaslang/?.class.
(In this example, kotlin-compiler-embeddable-1.2.21.jar does not need to be jetified but was jetified and then failed.)
We need a way to determine whether a third-party library should be jetified or not. There are a couple of approaches:
1. The library adds some metadata stating that it is AndroidX-ready and therefore should not be jetified. (The Android Gradle plugin can also help to add this information automatically for libraries that are built using the AGP.)
2. Jetifier automatically detects the presence of AndroidX (e.g., import statements and strings containing references to AndroidX), and if AndroidX is present, assumes that the library is AndroidX-ready and skips converting it.
3. The users need to specify a blacklist of libraries that should not be jetified.
We'll need to weigh the pros and cons of these approaches and select the best one (or a combination of them).