rharter / auto-value-gson

AutoValue Extension to add Gson De/Serializer support
Apache License 2.0
607 stars 103 forks source link

GenerateTypeAdapter proguard warning #162

Closed xdgimf closed 5 years ago

xdgimf commented 6 years ago

Updated to 0.7.0 and got this proguard warnings related to the new annotation @GenerateTypeAdapter. I haven't used it yet so I'm not really sure.

Here's the proguard warning

Warning: library class com.ryanharter.auto.value.gson.GenerateTypeAdapter$1 extends or implements program class com.google.gson.TypeAdapterFactory

Warning: there were 1 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.

Here's my dependencies

depedencies {
    //...
    compileOnly "com.jakewharton.auto.value:auto-value-annotations:$project.ext.autoValueAnnotationsVersion"
    compileOnly "com.ryanharter.auto.value:auto-value-gson:$project.ext.autoValueGsonVersion"
    annotationProcessor "com.google.auto.value:auto-value:$project.ext.autoValueVersion"
    annotationProcessor "com.ryanharter.auto.value:auto-value-gson:$project.ext.autoValueGsonVersion"
    annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$project.ext.autoValueParcelVersion"
    //...
    implementation "com.google.code.gson:gson:$project.ext.gsonVersion"
    //...
}

For now I simply ignored the warnings by adding the following rules:

-dontwarn com.ryanharter.auto.value.gson.GenerateTypeAdapter
-dontwarn com.google.gson.TypeAdapterFactory

Edit: Added Gson dependency

JakeWharton commented 6 years ago

Do you have a Gson dependency?

On Sun, Dec 31, 2017, 9:51 AM Miguel Fermin notifications@github.com wrote:

Updated to 0.7.0 and got this proguard warnings when i build a signed apk.

Warning: library class com.ryanharter.auto.value.gson.GenerateTypeAdapter$1 extends or implements program class com.google.gson.TypeAdapterFactory

Warning: there were 1 instances of library classes depending on program classes. You must avoid such dependencies, since the program classes will be processed, while the library classes will remain unchanged.

Here's my depedencies

depedencies { //... compileOnly "com.jakewharton.auto.value:auto-value-annotations:$project.ext.autoValueAnnotationsVersion" compileOnly "com.ryanharter.auto.value:auto-value-gson:$project.ext.autoValueGsonVersion" annotationProcessor "com.google.auto.value:auto-value:$project.ext.autoValueVersion" annotationProcessor "com.ryanharter.auto.value:auto-value-gson:$project.ext.autoValueGsonVersion" annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$project.ext.autoValueParcelVersion" //... }

For now I ignored the warnings by adding the following rules:

-dontwarn com.ryanharter.auto.value.gson.GenerateTypeAdapter -dontwarn com.google.gson.TypeAdapterFactory

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-gson/issues/162, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEQDEtXXlyHeOAoKSj7B4cAMf5yK2ks5tF59dgaJpZM4RP3aW .

xdgimf commented 6 years ago

Yes, I have a Gson dependency.

adin234 commented 6 years ago

any updates on this?

ZacSweers commented 6 years ago

Only thing I can think of is that proguard is complaining that there's code in the annotations artifact that isn't there at runtime because you're not compiling the annotations. There's a full TypeAdapterFactory implementation in the GenerateTypeAdapter annotation code

ZacSweers commented 5 years ago

Closing this out, but the rules above should suffice. Unfortunately we can't solve this with an embedded proguard file as these would be compileOnly and presumably not reach proguard/R8 tools to index on