简体   繁体   中英

How to sign android apk without android studio

我在此问题上发现了许多令人困惑的答案:如何在没有Android Studio的情况下签署(发布/调试)Android应用程序(例如,在签署ionic / cordova / phonegap应用程序时签署)?

You can Add Key store in Gradle file.

 android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}

--> use CMD for generate signed APK.

gradlew assemblerelease.

So, the right and simple answer to date is:

  1. cd into your project platform/android folder (might just be your main project folder if not cordova/ionic build). You should find your main build.gradle file in that folder.
  2. Create a keystore file by calling:

    \nkeytool -genkey -v -keystore .keystore -alias -keyalg RSA -keysize 2048 -validity 10000 \n

    Follow along and fill in and passwords (write them down in a place you'll find them!)

  3. Create two files named: debug-signing.properties and release-signing.properties

  4. Enter the following configuration to both (you can later change the keystore to harden the security for release build...):

    \nkeyAlias=ALIAS_NAME \nkeyPassword=ALIAS_PASSWORD \nstoreFile=KEYSTORE_FILE_NAME \nstorePassword=KEYSTORE_PASSWORD` \n
  5. Run build ...

Ionic team giving a great idea about this query you can follow this link and you can do this with in 10 min's

http://ionicframework.com/docs/guide/publishing.html

But You need android sdk to do this ...

To set ANDROID_HOME

Windows

set ANDROID_HOME=Path to sdk 

Linux Based Systems

export ANDROID_HOME=Path to sdk

Steps to Follow

  1. Create release app

  2. Create keystore

  3. Signing the APK

I had the same problem. The easiest solution is to come back to the fundamentals through the DOS commands keytool and jarsigner. Note that these files must be located in the jdk directory to work well.

Only two actions to do:
- to use keytool for creating your keystore and your certificate(s):the first certificate is created when you create the single keystore. Then, the other certificates will be created by calling again the keytool command with the same keystore name
- then to use jarsigner. Prefer to differentiate the jar input filename and the generated signed jar filename when you prepare your jarsigner command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM