"Android" Android Studio for code obfuscation, packaging release APK

Source: Internet
Author: User

The whole day, feeling a lot of pits.

1. Select the option in Android studio to sign package:

2. Fill in the information of the app: (preferably with a text note to put in the project synchronization to team)

-Key Store Path: If the new app is created, if you already have a selection on the line;

-Key Store Password: *******

-Key alias (alias): Custom

-If the newly created file needs to be selected time, the whole 25 is enough, the company information fill in OK

-Choose release after the next step to start packing

3. The obfuscation feature of Android studio needs to be added in Gradle:

Apply plugin: ' Com.android.application 'Android {compilesdkversion19buildtoolsversion' 23.0.1 'Defaultconfig {ApplicationID"Com.rayclear.juchang"minsdkversion17targetsdkversion23Versioncode4Versionname"1.03"} buildtypes {release {//code obfuscation switch, be aware that you are now using minifyenabled instead of Runproguard.Minifyenabledtrue            //Proguard-rules.pro is the currently used obfuscation file (proguard.cfg in Eclipse)Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '}} packagingoptions {exclude' Meta-inf/dependencies 'Exclude' Meta-inf/license 'Exclude' Meta-inf/license.txt 'Exclude' Meta-inf/license.txt 'Exclude' Meta-inf/notice 'Exclude' Meta-inf/notice.txt 'Exclude' Meta-inf/notice.txt 'Exclude' meta-inf/asl2.0 '} compileoptions {sourcecompatibility javaversion.version_1_7 targetcompatibility JavaVersion.VE Rsion_1_7}}

4. Problems with Packaging:

1 . Always in Gradle Build Running ... Was the pit two times, always thought is really in packing, IDE also wood has a specific hint what, wait for a long time. In this case, just turn off Android studio and start over again. Normally it's 1-3 minutes for a normal app to be confused. 2 . About Cache.properties.lock's error:error:timeout waiting to lock cp_projclassCache forBuild file '/users/raomengyang/work/app/build.gradle ' (/users/raomengyang/.gradle/caches/2.8/scripts/build_ aldsk0ke4ednnd4pf0nybqlhq/cp_proj). It is currently in use by another Gradle instance. Owner pid:unknownour PID:20080Owner operation:unknownour operation:initialize cachelock file:/users/raomengyang/.gradle/caches/2.8/scripts/build_aldsk0ke4ednnd4pf0nybqlhq/cp_proj/Cache.properties.lock before encountered the same situation, is the file with lock to restore permissions to solve, but this time no use, so quit as re-come, each encounter this problem and then quit as will prompt backstage and the task is not finished, so this error personal feeling is as there are background tasks It's not over, it's always here. 3 . Various specified twice:java.io.IOException:The same input jar [/users/raomengyang/work/app/libs/**] is specified twice. Delete the jar file referenced by the duplicate declaration in the Proguard file. 4. The sky Warning:      Note:there were 157 duplicate class definitions. (http://proguard.sourceforge.net/manual/ troubleshooting.html #duplicateclass) Warning:library class Org.apache.http.auth.AuthenticationException extends or implements program Class Org.apache.http.ProtocolExceptionWarning:library class Org.apache.http.auth.MalformedChallengeException Extends or implements program class Org.apache.http.ProtocolExceptionWarning:library class Org.apache.http.auth.params.AuthParamBean extends or implements program class Org.apache.http.params.HttpAbstractParamBeanWarning:library class Org.apache.http.client.NonRepeatableRequestException extends or implements program class Org.apache.http.ProtocolExceptionWarning:library class Org.apache.http.client.RedirectException extends or Implements program Class Org.apache.http.ProtocolExceptionWarning:library class Org.apache.http.client.entity.UrlEncodedFormEntity extends or implements program class Org.apache.http.entity.StringEntityWarning:library class Org.apache.http.client.methods.HttpEntityEnclosingRequestBase extends or implements program class Org.apache.http.HttpEntiTyenclosingrequestwarning:library class Org.apache.http.client.methods.HttpRequestBase extends or implements program Class Org.apache.http.message.AbstractHttpMessageWarning:library Class Org.apache.http.client.methods.HttpUriRequest extends or implements program class Org.apache.http.HttpRequestWarning : library class Org.apache.http.client.params.AllClientPNames extends or implements program class Org.apache.http.params.CoreConnectionPNames ..... ..... ..... ..... ..... ................-.....-........ ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ....... ....... Warning........................................................................................................................................................................................................................................................................................................................ ............................................................................................................ Warning........................................................................................................................................................................................................................................................................................................................ ............................................................................................................ Warning........................................................................................................................................................................................................................................................................................................................ ............................................................................................................ Warning ..... ..... ..... ..... ..... ................-.....-........ ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ....... ....... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...... ....... ....... ..... ..... ..... ..... ..... ..... ..... ....... ....... ..................................................................................................................................................................................................................... Warning........................................................................................................................................................................................................................................................................................................................ ............................................................................................................ Warning........................................................................................................................................................................................................................................................................................................................ ............................................................................................................ Warning........................................................................................................................................................................................................................................................................................................................ Warning:library class Org.apache.http.client.params.AllClientPNames extends or implements program class Org.apache.http.params.CoreProtocolPNamesWarning:library class Org.apache.http.client.params.ClientParamBean Extends or implements program class Org.apache.http.params.HttpAbstractParamBeanWarning:library class Org.apache.http.client.protocol.RequestAddCookies extends or implements program class Org.apache.http.HttpRequestInterceptorWarning:library class Org.apache.http.client.protocol.RequestDefaultHeaders extends or IMplements Program Class Org.apache.http.HttpRequestInterceptorWarning:library class Org.apache.http.client.protocol.RequestProxyAuthentication extends or implements program class Org.apache.http.HttpRequestInterceptor This kind of problem can be based on our class file to make the following declaration: For example: Now the hint is org.apache.http.* the class in this package has a problem, Then add the following code:-keep class org.apache.http.** {*;} -dontwarn org.apache.http.** and so on, note that after the confusion, even if the package succeeds, it needs to be tested again, because the problem may occur inside the app.

"Android" Android Studio for code obfuscation, packaging release APK

Related Article

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.