If the project introduces the jar class library for the android-support-v4, an error message appears when the project is packaged for obfuscation. For example, you may need to specify additional library jars (using '-libraryjars ').
The solution is provided here, and we will explain how to deal with similar situations later:
Add the following content after proguard. cfg:
[Java]
-Libraryjars/android-support-v4.jar
-Dontwarn Android. Support. v4 .**
-Keep class android. Support. v4 .**{*;}
-Keep public class * extends Android. Support. v4 .**
-Keep public class * extends Android. App. Fragment
Then you can package it and check that the APK installation package can be generated normally.
Packaging error:
Scenario 1:
"Class 1 can't find referenced class Class 2" literally means Class 1 cannot find the reference of Class 2; It will suggest you: "You may need to specify additional library jars (using '-libraryjars '). ";
You need to use-libraryjars and the third-party libraries used in the project.
Example:-libraryjars/android-support-v4.jar
Note: The reference method here is the root directory of the current project (other directories can also be configured), that is, you need to put the third-party jar under the current directory, otherwise, a warning is reported that the JAR file cannot be found!
Scenario 2:
For example, can't find superclass or interface Android. OS. parcelable $ classloadercreator. In this case, you can use-dontwarn com. XX. yy. ** to warn against errors.
Note: to use this method, make sure you do not use the class in this library! Otherwise, the classnotfoundexception will be thrown!
Case 3:
This class is indeed used in the project, but the above method still does not work. At this time, we need to add another item:-keep class com. XX. yy. ** {*;}, so that the current class is not confused.
Summary:
To reference a third-party package, use the following method to avoid packaging errors:
-Libraryjars/AAA. Jar
-Dontwarn com. XX. yy .**
-Keep class com. XX. yy .**{*;}
Finally, the package is successful, and you have to run on the machine to see if there are any problems.