Android programming to solve the problem of android-support-v4 Packaging

Source: Internet
Author: User

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:
-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.
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.

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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.