Android studio: apk release not signed

* I paraphrased the post since it was originally published *

When I try to launch the newly released apk, I get the error message "apk for the option you selected ... not signed." This is in the "Edit Configuration" pop-up menu. Here are my steps:

  • On the Build Options tab, select release
  • From the menu, select Build → Generate Signed APK
  • Fill in the fields for the keystore and password storage in the drop-down list.
  • In the second panel, change the destination folder to ... \ app \ build \ output \ apk (see note * below)
  • Observe the notification in the upper right corner of the studio: APKs generated successfully.
  • From the menu, select Run → Run Application.
  • I get an “Edit Configuration” pop-up with an Apk error for the option you selected ... not signed.

So why this error? The generated APK appears to be valid. I successfully posted it on the Android Store (for alpha testing only) and verified that the stack dumps are messy.

What I cannot do is download it (step 6 above) to my device. I think this is normal, since I can download the debug version just fine.

(*) Android Studio by default displays a higher, supposedly more convenient directory for apk release. However, it’s more difficult for me to control the consistency of the generated files when they are scattered, so I prefer all the generated apks in one place.

+16
android studio release
source share
7 answers

Go to file \ Project Structure

Caption tab

Tab

Assembly type

Done !;)

+22
source share

Set the subscription configuration in the project structure.

  • File → Project Structure ...
  • Select modules / application (or another module)
  • Click the Signature tab and fill out.
    In the first place appears the key alias and key password . Not the same order in the Create Signature APK dialog box.
  • Click the Build Types tab and select a release.
    Select "config" from the "Configuration" drop-down list.
  • Click OK to close the project structure.
  • Launch → Launch Application

Launching (or debugging) the application seems to be using apks created using the "Buiild → Build APK". So, we have to set the signature config if the build options for the application module are “released”.

+18
source share

Add this line to your release {...} inside build.gradle

signingConfig signingConfigs.config 
+5
source share

First create a keystore file if it is not.

  1. Click Build from the drop down menu.
  2. Select Create Signed APK
  3. Click Next
  4. Click Create New Key Vault
  5. Fill out the form for the keystore, alias, password for the keystore and alias, at least one field in the certificate area.
  6. Click OK
  7. The keystore file must be created at the specified keystore path.

Second, upgrade your application build Gradle file to a type that includes signature configuration.

 android { signingConfigs { config { keyAlias 'mykeyalias' keyPassword 'android' storeFile file('/Users/yourname/path/to/the/android/project/folder/android_project_folder_name/app/debug.keystore') storePassword 'android' } } buildTypes { debug { applicationIdSuffix = ".debug" versionNameSuffix "-debug" } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config } } } 

Third , assemble and run the application, ready.

+3
source share

At https://developer.android.com/studio/publish/app-signing#secure-shared-keystore it says that you should not store permission information in build.gradle and VCS. So create a signature configuration file (Create> Create Signed APK) and then do it.

Create a file called keystore.properties in the root directory of your project. This file should contain your information for signature, namely:

 storePassword=myStorePassword keyPassword=mykeyPassword keyAlias=myKeyAlias storeFile=myStoreFileLocation 

In the module build.gradle file, add the code to load your keystore.properties file before the android {} block.

 // Create a variable called keystorePropertiesFile, and initialize it to your // keystore.properties file, in the rootProject folder. def keystorePropertiesFile = rootProject.file("keystore.properties") // Initialize a new Properties() object called keystoreProperties. def keystoreProperties = new Properties() // Load your keystore.properties file into the keystoreProperties object. keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { ... } 

You can reference the properties stored in keystoreProperties using the syntax keystoreProperties['propertyName'] . Modify the signingConfigs block of your module build.gradle file build.gradle that it build.gradle to the signature information stored in keystoreProperties using this syntax.

 android { signingConfigs { config { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } ... } 

If desired, in build.gradle you can add:

 buildTypes { release { ... signingConfig signingConfigs.config } } 

Now you can make a signed apk. Remember to exclude keystore.properties from VCS.

+1
source share

Try adding this to your build file:

 buildTypes { release { signingConfig signingConfigs.release minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { minifyEnabled false } } 
0
source share

I had the same problem, I am incorrectly signingConfigs property of signingConfigs .

In particular, I thought that I did not have a password for the key that I actually set. After adding the missing information, it worked.

 signingConfigs { config { keyAlias 'key0' storeFile file('C:/Users/xxx/xxx/keystore/xxx.jks') storePassword '123' keyPassword '123' // this was missing } } 
0
source share

All Articles