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)?
问题:
回答1:
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.
回答2:
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
Create release app
Create keystore
Signing the APK
回答3:
So, the right and simple answer to date is:
- 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.
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!)
Create two files named:
debug-signing.properties
andrelease-signing.properties
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`
Run build ...
回答4:
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