Let Android Studio support system signing (certificate)

Source: Internet
Author: User

Go from https://my.oschina.net/connorlin/blog/66807651557025 Summary: Automatically package system signatures using Android Studio Sometimes, the apk we developed needs to use system permissions, You need to add shared system process properties in Androidmanifest.xml: android:shareduserid= "Android.uid.system" android:shareduserid= " Android.uid.shared "android:shareduserid=" Android.media "This time the APK signature needs to be a system signature (platform, shared, or media) for normal use. Common system Signature mode Android source code environment signature This way is more troublesome, you need to have compiled the source environment, and the following steps: 1, copy the app source code to the Android source packages/apps/directory, and the app source code is normal (Eclipse) format 2, configure ANDROID.MK, add local_certificate: = Platform or shared or MEDIA3, use mm to compile the app, the generated apk is the system signature manual re-signing this way than in the source environment, the signature is simple, The app can be compiled under Eclipse or Android studio and then re-sign the APK. But this kind of method is more painful when debug frequently, even if write a script, also need to repeat the same operation. Related files Platform.x509.pem, platform.pk8, Signapk.jar file location Platform.x509.pem, Platform.pk8:.. /build/target/product/securitysignapk.jar:.. /out/host/linux-x86/frameworksignapk source path:.. /build/tools/signapk signing Command Java-jar Signapk.jar PLATFORM.X509.PEM platform.pk8 old.apk new.apk Step 1, place the relevant files and source APK files under the same path 2 , check the source apk package, remove the Meta-inf/cert. SF and Meta-inf/cert. RSA file 3, execute signature command to have Android studio system signature let Android Studio integrated system signature, need to use aTool Keytool-importkeypair, see below. Keytool-importkeypairkeytool-importkeypair–a shell script to import key/certificate pairs into an existing Java KeyStore The purpose of this tool is to import information about the system signature into an existing signature file. Can be downloaded from here. Tools can be used by--help or readme.textile for assistance, or refer to the article using the Keytool tool. Related documents PLATFORM.X509.PEM, PLATFORM.PK8, Keytool-importkeypair, Demo.jks, Signature.sh my practice is to create a new signature folder in the app root to store signature-related files exclusively. Step 1, generate the Demo.jks signature file 2, write the signature script signature.sh, the contents are as follows: #!/bin/sh# conversion Platform signing command./keytool-importkeypair-k demo.jks-p 123456-pk8 Platform.pk8-cert platform.x509.pem-alias demo# Demo.jks: Signature File # 123456: Signature file Password # PLATFORM.PK8, Platform.x509.pem: System Signature Text Piece # Demo: Signature file alias Add executable permissions to the script file: $ sudo chmod a+x signature.sh Execute script: $./SIGNATURE.SH3, configuring Builde.gradle under the Android region ( Add configuration to Defaultconfig sibling): signingconfigs {release {StoreFile file (".. /signature/demo.jks ") Storepassword ' 123456 ' Keyalias ' demo ' Keypassword ' 123456 '} debug {StoreFile file (". /signature/demo.jks ") Storepassword ' 123456 ' Keyalias ' demo ' Keypassword ' 123456 '}} This way the debug or release apk comes with a system signature. If you want to direct RUN app is release version with system signature APK, also need to modify: Variant App modified Buildtypes:buildtypes {release {minifyenabled false proguardfiles Getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.txt ' Signingconfig Signingconfigs.release}} So the direct run app is the release version with the system signature apk.

Let Android Studio support system signing (certificate) (GO)

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.