How to sign android apk without android studio

2019-09-16 09:27发布

I have found many many confusing answers on this one: How do I sign (release/debug) android app without Android Studio (E.g. when signing ionic/cordova/phonegap app)?

4条回答
聊天终结者
2楼-- · 2019-09-16 10:09

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.
查看更多
ら.Afraid
3楼-- · 2019-09-16 10:09

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:

    keytool -genkey -v -keystore .keystore -alias  -keyalg RSA -keysize 2048 -validity 10000
    

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

    keyAlias=ALIAS_NAME
    keyPassword=ALIAS_PASSWORD
    storeFile=KEYSTORE_FILE_NAME
    storePassword=KEYSTORE_PASSWORD`
    
  5. Run build ...

查看更多
虎瘦雄心在
4楼-- · 2019-09-16 10:16

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

查看更多
SAY GOODBYE
5楼-- · 2019-09-16 10:17

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

查看更多
登录 后发表回答