Use proguard for the cocos2dx Project

Source: Internet
Author: User

Encryption is required if your application is to be installed on googleplay. The android SDK has integrated proguard. Therefore, the entire process is much easier.

Add a line of proguard. Config = proguard. cfg to the project. properties file under proj. Android.

Then copy the {Android-SDK-root} \ tools \ proguard \ proguard-android.txt and rename it proguard. cfg. (Here is another one with optimize. For more information, see the instructions in this file .)

 

If your project is integrated with a third-party jar library, you can add the following options as below to ensure that you have no problems.

1. Add external reference

-Libraryjars./libs/tapjoyconnectlibrary. Jar
-Libraryjars./libs/chartboost. Jar
-Libraryjars./libs/crashlytics. Jar
-Libraryjars./libs/in-app-purchasing-2.0.1.jar

2. Specify not to be confused and do not prompt the following package errors (this is a third-party package, we want to protect our own code, so there is no need to confuse it)

-Keep class com. tapjoy .**{*;}

-Keep class com. Amazon .**{*;}
-Dontwarn com. Amazon .**
-Dontwarn com. tapjoy .**

NOTE: If your SDK clearly tells you which system libraries cannot be ignored, You need to manually specify them. For example, tapjoy makes it clear that you want to add the following code.

-Keep class com. tapjoy .**{*;}
-Keepattributes javascriptinterface
-Keep class * extends java. util. listresourcebundle {
Protected object [] [] getcontents ();
}
-Keep public class com. Google. Android. GMS. Common. Internal. safeparcel. safeparcelable {
Public static final *** NULL;
}
-Keepnames @ com. Google. Android. GMS. Common. annotation. keepname class *
-Keepclassmembernames class *{
@ Com. Google. Android. GMS. Common. annotation. keepname *;
}
-Keepnames class * implements Android. OS. parcelable {
Public static final ** creator;
}
-Keep class com. Google. Android. GMS. Ads. identifier .**{*;}

 

 

Iii.-Keep class org. cocos2dx. Lib .**{*;}

This addition prevents the code of org. cocos2dx. Lib from being removed by proguard. Because proguard will help you delete unreferenced code. ,

Your org. cocos2dx. Lib is called by JNI, and proguard cannot find your reference to it, so it will be removed by default. Therefore, you can only specify it manually. Otherwise, the game cannot be started.

 

4. add your own JNI code.

Like org. cococs2dx. Lib, if you provide a JNI class that requires C ++ calls, you must manually specify the reserved class. For example

-Keep class com. dreamhunters. JNI {*;}

Use proguard for the cocos2dx Project

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.