android studio 3.5 Warning: The rule `-keep public class * extends androidx.versionedparcelable.VersionedParcelable { <init>(); }` uses extends
Asked Answered
I

2

24

Today, I updated my Android Studio to 3.5. After updated, I found below warning when I try to run the app.

The rule -keep public class * extends androidx.versionedparcelable.VersionedParcelable { (); } uses extends but actually matches implements.

I know warning is related with my proguard rules. So, I double checked my proguard rule file, but I am sure I didn't add that rule and it is not in my proguard rule file.

My Progurad File

Below is the warning when I build the project.

enter image description here

My project is using AndroidX. Can anyone know that warning can be skipped or where that warning came from? Any ideas or alternative ways will be appreciating..

Insatiable answered 22/8, 2019 at 4:2 Comment(15)
that's because VersionedParcelable is an interface, which can be only implemented, not extended. Are you using the default proguard rules file in addition to your one?Hyperbola
sorry. Can you rephrase? I am using my own progurad rules.Insatiable
can you show the line in your build.gradle where you are using your own proguard rules file?Hyperbola
@Vladyslav, please see below link drive.google.com/file/d/1irtc0DhMIlUl02moCbbWt2wqPXiH6W0A/…Insatiable
you are using the default proguard file getDefaultProguardFile(..). It has some proguard rules too. This line is likely from itHyperbola
P. S. Please stop showing images of code. Show only text.Hyperbola
@VladyslavMatviienko,can I know the problem is bcoz of defaultProgurardFile()?Insatiable
you can search in that file for the line specified in errorHyperbola
@VladyslavMatviienko. Thank you. But, can I know default progurad file is the progurard file that I showed in question? Is itn't?Insatiable
no, it is proguard-android.txt located somewhere in Android SDK dirHyperbola
sorry. I can't follow what you mean.Insatiable
getDefaultProguardFile loads the default proguard rules file located in Android SDK directory in addition to your custom rules fileHyperbola
now I understood. Thank you. But, let me know, if we use progurard, can we drop default progurad? or just add addition?Insatiable
I personally don't use default one. You can use `proguardFile 'proguard-rules.pro' instead of that lineHyperbola
https://mcmap.net/q/455717/-how-to-add-code-obfuscation-for-my-android-applicationGooden
B
32

It's a bug in the proguard.txt file in the versionedparcelable.aar version 1.0.0. This was fixed in version 1.1.0, however, if you're not using libraries that depends on the new version you'll get this warning in Android Studio 3.5.

In version 1.0.0 the proguard.txt file includes the following line:

-keep public class * extends androidx.versionedparcelable.VersionedParcelable

This was fixed in version 1.1.0:

-keep public class * implements androidx.versionedparcelable.VersionedParcelable

To bypass this issue you can force using the latest version by adding the following line to your build.gradle:

implementation "androidx.versionedparcelable:versionedparcelable:1.1.0"
Blubber answered 24/8, 2019 at 20:11 Comment(0)
B
1

Why not do this for that project:

  1. Disable minify in "build.gradle (Module: app)" file:
minifyEnabled false
  1. and you use proguard for optimization, such as:
proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt')
Belsky answered 19/12, 2019 at 18:58 Comment(2)
Too, You can update to compileSdkVersion 29 and migrate to AndrodX. This is the best solution.Belsky
Yes, but that was a fast and easy solution then.Agree?Belsky

© 2022 - 2024 — McMap. All rights reserved.