Error building Android app in release mode, in Android Studio - android

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')

Related

How come when I generate a signed APK it produces out a JKS file?

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

How to sign debug APK's with the same key as release APK's - Android Studio

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.

How can I sign testing apk in Android Studio?

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.

Generate Released apk using keystore in teamcity Android

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!

Installation failed since the APK was either not signed

I just upgraded my Android Studio from 1.5 to 2.2, and now when running my App I get the error:
Installation failed since the APK was either not signed, or signed
incorrectly. If this is a Gradle-based project, then make sure the
signing configuration is specified in the Gradle build script.
I already googled for it, and nothing worked for me, my gradle file is:
...
android {
signingConfigs {
myapp_signed {
keyAlias 'mkey'
keyPassword 'pwd'
storeFile file('.../_keystore.jks')
storePassword 'pwd'
}
}
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId '...'
minSdkVersion 14
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.myapp_signed
}
}
productFlavors {
}
}
...
Does anybody know how to solve this? Right before I got this error, I got another error, which was saying:
Warning:Gradle version 2.10 is required. Current version is 2.2. If
using the gradle wrapper, try editing the distributionUrl in
C:\Users\blahblah\myproject\gradle\wrapper\gradle-wrapper.properties
to gradle-2.10-all.zip
which I solved like this "Gradle Version 2.10 is required." Error
EDIT:
Even if I switch build variants back to debug, uninstall the app and try it again I get the same error.
For me the solution was, to update all the libraries I used and update to Android 23.
Maybe this helps somebody.
By default, Android Studio 2.2 and the Android Plugin for Gradle 2.2 sign your app with Signature Scheme v2. add v2SigningEnabled false to signingConfigs may solve your problem.
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
v2SigningEnabled false
}
}
ref. https://developer.android.com/preview/api-overview.html#apk_signature_v2
For reference, my signing configs look like this - not my real passwords :
signingConfigs {
release {
storeFile file("keystore/release.jks")
keyAlias "release"
storePassword "storepass"
keyPassword "keypass
}
debug {
storeFile file("keystore/debug.jks")
keyAlias "androiddebugkey"
storePassword "android"
keyPassword "android"
}
}
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
signingConfig signingConfigs.release
}
debug {
minifyEnabled true
zipAlignEnabled true
signingConfig signingConfigs.debug
}
}
Did you try to generate a new keystore to use?
In my case, my old keystore file is not working anymore after I upgrade from gradle build tools 1.5.0 to 2.1.0
It surprise me when I try it out...
Apparently the issue is bug us with downgrading gradle to version 2.1.0
classpath 'com.android.tools.build:gradle:2.1.0'
if you still get this error even in debug mode then just Clean your project and Run again. That worked out for me
P.S: I am using Android 2.2 Beta

Categories

Resources