I am exploring Android app in teamcity.I have already install teamcity plugins in android studio.its working fine.but i want to generate signed apk using teamcity tool. can anyone help me Which build step included to generate signed apk?
Thanks in advance.
You can add your keystore file to the project and "call" it from the build.gradle file.
Add the Keystore file to:
MyApp/app/keystore.jks
Then use add the following to you build.gradle, this has to go in front of the buildTypes:
signingConfigs {
release {
storeFile file("keystore.jks")
storePassword "password"
keyAlias "MyKey"
keyPassword "password"
}
}
In the buildTypes just refer to the signining config by adding the following line:
signingConfig signingConfigs.release
You should end up with something like this:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
To verify that the apk is signed you can use the following command:
%JDK.Path%/jarsigner -verify MyApp/app/build/outputs/apk/MyApp.apk
The %JDK.Path% to be replaced with your JDK path like this:
C:\Program Files\Java\jdk1.8.0_121\bin
Good luck!
Related
I'm using the newest version of Android Studio and I am looking at publishing an app on the Play store. Unfortunately when I generate a signed APK it only gives me the open to produce a JKS file. All the tutorials I've seen makes it look like you put an APK and that's what you get out, but those are using older versions of Android studio. Do I need to put the JKS file through something else, download an older version of Android Studio or am I missing a step? I'm really new at this and I'd appreciate any help I can get. Thanks!
You need to create a JKS file once. After that make sure You have something like this in Your gradle file, inside "android" part:
signingConfigs {
config {
keyAlias 'key'
keyPassword '123456'
storeFile file('../app/key/yourAppKey.jks')
storePassword '123456'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
After this part has been added just set build variant -> release and then use build -> build bundle/apk -> build apk
I have bought an android app source code from codecanyon. I want to generate android apk for distribution without android studio. Any alternative?
Reason:
I have some problem installing android studio in my pc which makes it impossible to use android studio.
You should specify signingConfigs and buildTypes in build.gradle's android block. For example:
android {
defaultConfig {
...
}
signingConfigs {
config {
keyAlias '...'
keyPassword '...'
storeFile file('../key.jks')
storePassword '...'
}
}
buildTypes {
debug {
useProguard false
minifyEnabled false
debuggable true
applicationIdSuffix '.debug'
}
release {
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
useProguard true
minifyEnabled true
debuggable false
shrinkResources true
}
}
}
Then from terminal or command prompt in root path of your project, run the following commands:
// To generate debug apk
gradlew assembleDebug
// To generate release apk
gradlew assembleRelease
yes you can do it in command line. see the tutorial from official site with this link
I want to test in-app purchasing within my app, but it seems impossible to do this with a regular debug APK through Android Studio? Has anyone done this before and if so what steps did you take to do it?
I was thinking to get around it I should try signing my debug APK's in the same way I sign my release APK's. How can I do this?
You can config that in your android studio, right click your project, chose the open module settings
Or if you are crazy about the hand-writen build scripts, here is a snapshot of code:
android {
signingConfigs {
release {
storeFile file(project.property("MyProject.signing") + ".keystore")
storePassword "${storePassword}"
keyAlias "${keyAlias}"
keyPassword "${keyPassword}"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}
}
Just config your debug and release build type with same signingConfig.
I am developing an app in such an android device that requires each app to be signed with a specific key, even the testing apk.
I know how to sign an app by configuring build.gradle. But signing testing app (Instrumentation test) seems no such configing, am I missing something ?
try this in build.gradle
signingConfigs {
release {
keyPassword 'your pw'
storeFile file('your keystore file path')
storePassword 'your pw'
keyAlias 'your alias'
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
signingConfig signingConfigs.release
}
}
Thanks for NateZh and TWL.
Yes, the answer is to add flowing lines to build.gradle:
signingConfigs {
debug {
keyPassword 'your pw'
storeFile file('your keystore file path')
storePassword 'your pw'
keyAlias 'your alias'
}
}
But, there are more to be take care of:
When using signingConfigs.debug, this tells gradle it's debug key, no need to specific buildTypes.debug.signingConfig again
SigingConfigs.debug also take effect when building instrumentation test
In multi-modules project, if you want to test a module, you should include signingConfigs.debug in the module's build.gradle.
For example, my project looks like:
app
-build.gradle
libs
-src/androidTest/java/com/my/MyTest.java
-build.gradle
Adding signingConfigs.debug to app has no effect when I want to run libs' AndroidDebugTest. Instead, adding signingConfigs.debug to libs' build.gradle do the work.
Hope it's helpful to others.
I'm trying to sign my android app in release mode, in Android Studio.
I followed this official guide. So I have created the keystore and a private key. Then I tried to Generate the Signed APK, from Build -> Generate Signed API Key. But the build fails, with the following error:
:app:packageRelease FAILED
Error:A problem was found with the configuration of task ':app:packageRelease'.
> File 'C:\Documents\myapp\android.jks' specified for property 'signingConfig.storeFile' does not exist.
I have also checked the build.gradle configuration. And I have found this:
signingConfigs {
releaseConfig {
keyAlias 'xxxxxxxxxx'
keyPassword 'xxxxxxxxx'
storeFile file('C:\Documents\myapp\android.jks')
storePassword 'xxxxxxxxx'
}
}
but in the same gradle file I have this:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
}
}
What's wrong?
Replace \ by \\:
storeFile file('C:\\Documents\\myapp\\android.jks')
I have solved the problem, simply moving the keystore inside the base path of my android project.
Place the keystore file in app folder of that project, and replace with following
storeFile file('android.jks')