johncarl81 / parceler

:package: Android Parcelables made easy through code generation.
http://parceler.org
Apache License 2.0
3.56k stars 273 forks source link

Jetifier issue when using AndroidX #362

Closed virengujariya closed 5 years ago

virengujariya commented 6 years ago

Failed to transform '/Users/latergram/.gradle/caches/modules-2/files-2.1/org.parceler/parceler/1.1.11/98501bf35dc8296db0e31146ddd26c57b3952ef4/parceler-1.1.11.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4.widget' 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.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.

virengujariya commented 6 years ago

Now I need to keep enableJetifier set to true for dagger to work so can't set it to false

johncarl81 commented 6 years ago

@virengujariya, admittedly I havent been able to focus on the androidx stuff... do you have the ability to put together a quick project to demonstrate this issue so I can troubleshoot it?

virengujariya commented 6 years ago

@johncarl81 When creating new project I realized it works fine there. I think it could be a cache issue. Trying every possible options to clean cache and re build but so far no luck. Will keep looking and update if found fix.

virengujariya commented 6 years ago

Looks like you'll have to remove use of android.support.v4.widget Couple of references that could be helpful

SunnyDayDev commented 6 years ago

Same issue here. @virengujariya Have you started using AS 3.3.0-b3 or AS 3.4.0-a3? I suppose that begin from these AS versions Jetifier checks string literals which contain support library references, and fail if yes. Parceler have transfuse dependency which contain 'android.support.v4.app.*' literals in AndroidLiterals.java and I think that its the main reason. @johncarl81 I'll create empty project which reproduce the error.

SunnyDayDev commented 6 years ago

@johncarl81 https://github.com/SunnyDayDev/error-showcase-parceler-androidx Try run the project and you'll get the error.

virengujariya commented 6 years ago

@SunnyDayDev It still fails for same reason on AS 3.3 beta-3 Did it work for you?

johncarl81 commented 6 years ago

Was able to reproduce and I found the issue (thanks for a test case!)... here's the offending line of code from Transfuse: https://github.com/johncarl81/transfuse/blob/f892304a0306b5bb6f3f679c703b5075d3af6c99/transfuse-support/src/main/java/org/androidtransfuse/adapter/element/ASTElementFactory.java#L70 I think we can remove these lines because the issue has been resolved.

johncarl81 commented 5 years ago

Ok, issued a fix and pushed out parceler 1.1.12-SNAPSHOT to maven central if you want to try it out @SunnyDayDev @virengujariya

johncarl81 commented 5 years ago

BTW, here's how to try it out wiht @SunnyDayDev's example project:

git diff
diff --git a/app/build.gradle b/app/build.gradle
index 81d565a..9b70bcd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -31,7 +31,7 @@ dependencies {
     androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

-    implementation 'org.parceler:parceler-api:1.1.11'
-    kapt 'org.parceler:parceler:1.1.11'
+    implementation 'org.parceler:parceler-api:1.1.12-SNAPSHOT'
+    kapt 'org.parceler:parceler:1.1.12-SNAPSHOT'

 }
diff --git a/build.gradle b/build.gradle
index dddcebc..6c5eded 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,7 +19,9 @@ allprojects {
     repositories {
         google()
         jcenter()
-        
+        maven {
+            url "https://oss.sonatype.org/content/repositories/snapshots/"
+        }
     }
 }
virengujariya commented 5 years ago

Thanks @johncarl81

SunnyDayDev commented 5 years ago

@johncarl81, it's working fine) Thanks!

jbarr21 commented 5 years ago

@johncarl81 any chance we could get a non-snapshot release with this fix?

johncarl81 commented 5 years ago

Sure, I was thinking about waiting for the gradle plugin to leave beta, but my arm could be twisted.... I'll try to release 1.1.12 this evening/weekend.

johncarl81 commented 5 years ago

Ok, just released 1.1.12 with this fix.