I am attempting to generate a signed APK for my app. I'm using Android Studio to generate the release APK: build > generate signed APK. I then get a popup for my key store, alias, and passwords. This process has worked in the past but, I suspect, stopped working after a recent upgrade of tools and other support. What can I do to get Android Studio to generate the signed APK with a valid signature?
When I inspect the APK using jarsigner, from the Java 1.8 release, I get the message:
jar is unsigned. (signatures missing or not parsable)
If I use jarsigner to sign the app, it then installs on most devices but not on my device running Android 4.1. The command I used is:
jarsigner -verbose -keystore "...path...\perinote-release.keystore" app-release.apk perinote
Further, if I add to the jarsigner options:
-digestalg SHA1 -sigalg MD5withRSA
it is accepted by the Android 4.1 device. I found these options in another post, no manifest. jar is unsigned. (signatures missing or not parsable), indicating that there was, at some point, a change in the encryption from SHA1 to SHA2.
Here is my build.gradle for "app"
apply plugin: 'com.android.application'
android {
signingConfigs {
release {
keyAlias 'perinote'
storeFile file('...path.../perinote-release.keystore')
}
}
compileSdkVersion 24
buildToolsVersion "25.0.0"
compileOptions.encoding = 'UTF-8'
defaultConfig {
applicationId "com.perinote.camera"
minSdkVersion 15
targetSdkVersion 24
renderscriptTargetApi 20
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:24.0.0'
testCompile 'junit:junit:4.12'
}
What can I do to configure Android Studio to use SHA1 so that my app(s) will continue to work on Android 4.1 devices? Or is there something else I should be doing?
EDIT: I realize I should switch to SHA256. But I still need a way for my app to run on Android 4.1. Do I need to generate two versions and publish both of them?
To get both signature versions, simply check the checkboxes for V1 and V2 at the bottom of the 2nd Generate signed APK dialog box.
I hadn't noticed this dialog changed after updating AS and blew right past it.
Related
I am running into the following message when attempting to upload my APK as an alpha release on Google Play.
'You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play.'
In my gradle I have configured the signing config and build type(s) as follows:
signingConfigs {
release {
storeFile file("PATH TO KEY STORE")
storePassword "STORE PASSWORD"
keyAlias "ALIAS"
keyPassword "PASSWORD"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
testCoverageEnabled true
debuggable false
}
debug { testCoverageEnabled true }
}
Furthermore, I've verified using jarsigner that my APK was signed and that the CN does not contain CN=Android Debug.
The manifest for the APK does not contain the attribute android:debuggable.
The application I've built is a Kotlin application with the following dependencies:
Android Support v13 27.0.2
Android Support Annotations 27.0.2
Android Support Constraint Layout 1.0.2
Junit 4.12
Mockito 2.15.0
Robolectric 3.7
Android Support Test Runner 1.0.1
Android Support Test Espresso Core 3.0.1
I've attempted to upload the APK generated via gradle command line (i.e., gradle build) as well as the APK generated from the IDE using Build, Generate
Signed APK, and I've ensured that the release variant is selected when building from the IDE and gradle before attempting to upload to Google Play.
Finally, I've attempted this with multiple keystores (creating a new one thinking that perhaps my first one was invalid), and still I cannot upload my APK. To clarify, this is the first apk upload. No prior version exists on Google Play.
Is one of the support libraries leading to this issue, or is there something I have missed?
I discovered the issue.
It seems an APK with test coverage enabled is considered debuggable.
After removing the line
testCoverageEnabled true
from my release build type, I was able to upload my APK.
I've migrated from Eclipse on one Windows machine to Android Studio on a new Ubuntu machine. I'm struggling with AS. I've managed to copy a project across with ftp and have managed to run the debug version on an emulator on the Ubuntu machine. The release version which I have signed exists in the same place as the debug apk. When I select release as the build variant it wo't run saying:
The apk for your currently selected variant (app-release-unsigned.apk) is not signed. Please specify a signing configuration for ..
There is no such file below my project home directory, yet both the signed apks do exist
/home/nick/AndroidStudioProjects/GridMaps2.8/app/app-release.apk
/home/nick/AndroidStudioProjects/GridMaps2.8/app/app-debug.apk
My app gradle file is
apply plugin: 'com.android.application'
android {
signingConfigs {
debugFromAdventPC {
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
storeFile file('/home/nick/AndroidStudioKeystores/FromAdventPC/debug.keystore')
}
releaseFromAdventPC {
keyAlias 'release_alias'
keyPassword 'deleted'
storeFile file('/home/nick/AndroidStudioKeystores/FromAdventPC/my-release-key.keystore')
storePassword 'deleted'
}
}
compileSdkVersion 'Google Inc.:Google APIs:18'
//compileSdkVersion 15
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "deleted"
minSdkVersion 9
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile files('libs/osmdroid-android-4.1.jar')
compile files('libs/slf4j-android-1.5.8.jar')
}
Any help will be appreciated
It sounds like you are clicking on the green 'run' button in Android Studio. AS then dutifully tries to build and create a program to run. Which isn't really what you want. You want to test your release APK? Right?
To test your release APK:
Connect a phone to your computer with a USB cable.
Go to whatever file explorer software you are using on your Ubuntu machine.
Drag and drop your release APK to the phone, or ftp it over if your software can't handle that. Or you can try doing a command line move.
Use file manager software on your phone to locate the release APK file and click on it. It will unpack and install itself. Answer any questions as needed.
If you make changes you will have to uninstall the app from your phone, build the signed release APK again and do the copying and installation stuff all over again.
If you just wanted to edit your app on the Ubuntu machine in Android Studio, you need to move over all the original files. Eclipse should have an export function to help with that.
Hope that helps.
How do I get my SHA1 Keys for debug and release using android studio on a mac?
(These are required for Google API Keys)
DEBUG:
Click on the Gradle tab on the right hand side of the view.
Go to the ROOT folder -> Tasks -> android -> signingReport
Double click, this will build with the signingReport and post in your bottom view your SHA1.
RELEASE:
In android studio. Build -> Generate Signed APK... and click Next
Copy your key store path and key alias.
Traverse to the "bin" folder of the jdk path present in Java.
Open terminal and enter:
keytool -list -v -keystore "key store path" -alias "key alias"
Enter your key password and this will print out your release SHA1.
UPDATE:
In the new Google Developer console, it can be found at Setup -> App Integrity.
OLD ANSWER:
Here is the new easiest way to find release SHA-1 or other certificates:
I assume that you have already built signed APK and uploaded it to developer console.
Open google play console. Go to "Version Management", go to "Application Signing" and see your certificates.
Note: First google will ask you to activate "Application Signing" for your application.
For Debug Keystore
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
For release Keys
keytool -list -v -keystore {keystore_path_with_name} -alias {alias_name}
The entire process of generating certificate fingerprints SHA-1, SHA-256, MD5 for DEBUG as well as RELEASE are divided into the following 3 steps,
Create keystore properties
Load keystore To Gradle
Execute Gradle Task
For genertaing SHA-1 key for release build variant, you have to add
signingConfigs for release in your main module's build.gradle file.
Step 1 ) Add release details in gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "app.devdeeds.com.yourapplication"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
//Signing configurations for build variants "release"
signingConfigs {
release {
storeFile file("F:/Development/myapp.jks")
storePassword "231232das"
keyAlias "myapp_rel"
keyPassword "dasd333_das"
}
}
buildTypes {
//link above defined configuration to "release" build type
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
}
Step 2) open gradle menu from right menu bar and then app > android >
signingReport
Step 3) Click on signingReport and see the magic
As per new Google Play Console UI, the option is available at Setup >> App Integrity
For those who wants to generate release-apk SHA-1, SHA-256 and MD5 through Android Studio, follow these steps:
Goto Project Structure -> Default Config -> Signing Config and then add "RELEASE SHA1" using details provided during Generate-Signed-Apk. For e.g.,
Now set your Signing Config to $signingConfigs.'RELEASE SHA1'
Finally, change your build variant to release mode and run signingReport to generate Keys in release mode.
Hope that, this would definitely generate the release-apk KEYS in easiest way.
Here is simplest way to find SHA1 key Just open the terminal and Type follwing command
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
you found SHA1 key Like follow
SHA1: A1:A2:00:00:00:00:00:00:00:AA:00:00:00:00:00:00:00:A8:B2:00
thank you.
I'm new to Android Studio and running a debug build on a device is working fine, however to test in app purchasing (and obviously to release) I need a release build signed with the normal key. I can make an APK using Build -> Generate signed APK, however the package name seems to be incorrect. Here's my build file:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 9
testPackageName "com.company.common.common"
testInstrumentationRunner "android.common.InstrumentationTestRunner"
}
signingConfigs {
releaseConfig {
storeFile file("filname")
storePassword "password"
keyAlias "alias"
keyPassword "password"
}
}
buildTypes {
debug {
packageNameSuffix ".debug"
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.releaseConfig
}
}
productFlavors {
Flavor1 {
packageName "com.company.test"
}
}
}
dependencies {
// some dependencies
}
Note the package name overridden in the flavor. That flavor has no manifest; the only manifest is under main, and specifies a package of com.company.common. If I use Android to create a com.company.test APK and install it on a device, then generate an APK from Android Studio and install it, I end up with two apps on the device rather than the second replacing the first. This indicates that the package names are different, I assume because Android Studio is producing an APK with a package of com.company.common. Not sure how to verify that though.
When I just build the project, I get a debug APK but no release APK. How do I get a release APK with the correct package name? I just ran the app from Android Studio and it says it's installing com.company.test.debug, and that it needs to uninstall the app before installing. So now I'm thinking the generate signed APK generated a build with the debug package.
So far this is the issue that's preventing me from moving to Android Studio and gradle. Once I get past this I think I'm clear to move everything over so I'm hoping someone can help me figure it out!
Before you choose the Generate Signed APK option, go into the Build Variants window and choose the Release build variant. The Generate Signed APK command takes whatever the current build type is selected there and signs it. This obviously isn't what you want in this case; bug https://code.google.com/p/android/issues/detail?id=56532 is requesting improvements there.
I have a gradle-based android project and trying to generate a release apk. However, it seems that somehow gradle is picking up the wrong key/cert.
This is what I have in build.gradle:
signingConfigs {
release {
storeFile file("mykey.jks")
storePassword "mypass"
keyAlias "mykey.key"
keyPassword "mypass"
}
}
buildTypes {
release {
debuggable false
jniDebugBuild false
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
}
And after running
gradlew assembleRelease
and taking out META-INF/CERT.RSA from inside the .apk I run the following:
keytool -list -keystore mykey.jks
and
keytool -printcert -v -file CERT.RSA
but they produce output with different certificate fingerprints. Trying with a certificate from another apk signed with the same key (but not with gradle) yields the correct certificate fingerprint.
Gradle seems to be picking up the keystore fine (changing the password or location or alias makes it stop working).
I'm puzzled since I don't want to release something to the store signed with an unknown key and then not be able to update it. I don't have a debug key explicitly defined in gradle.
UPDATE: This has something to do with the keystore. Trying the same gradle code with a fresh keystore and key works fine. This problematic keystore was imported from a pkcs#12 format (.p12 file). Using Intellij or jarsigner works fine with this keystore though, it's just the gradle code that has a different output - and it seems only the certificate generated from the key is different.
In my case I was not aware I am using debug keystore file for release. In project/android/app/build.gradle
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug // <-- need to be changed with
//the line below
//signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
I faced the same issue while building signed .aab file with gradle.
It has to do with gradle caching issue.
I just restarted my gradle daemon threads running in my system and clean gradle cache.
./gradlew --stop
./gradlew clean
./gradlew bundleRelease
And it resolved the problem.
The only solution here was to start with a fresh key. The previous key had been imported from a PKCS12 format and I think that somehow caused the gradle code to generate a different certificate than jarsigner.