Android Studio 3.5.2 - Error: The apk for your currently selected variant (app-release-unsigned.apk) is not signed
Asked Answered
T

4

13

A little background. I have been building/debugging/testing my simple App for a few months with no problems. Build/install on AVD or my actual S9 phone. All worked just fine for months. Now, ready for my first beta release to the Play Store (my first app ever). So, I followed instructions on 'signing' my app. That worked and I uploaded my app bundle to the Play Store. Now I can't build/debug/install at all in Android Studio anymore.

Error: The apk for your currently selected variant (app-release-unsigned.apk) is not signed. Please specify a signing configuration for this variant (release).

enter image description here

Debug (Shift+F9) produces the above error and shows the "Edit configuration" dialog.

enter image description here

I click on the "Fix" button and from there I have no idea what to do. Or how to use these different build configurations.

enter image description here

build.gradle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        debug {
            storeFile file(var)
            storePassword 'xxx'
            keyAlias = 'xxx'
            keyPassword 'xxx'
        }
    }
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.birdersdiary.mobile"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "b1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Once I click on the "FIX" button I am taken to the "Run/Debug Configurations" dialog. And from there it is completely oblivious to me what needs to happen in order to Fix the problem.

Any assistance greatly appreciated.

Tangy answered 29/11, 2019 at 23:22 Comment(4)
You should set singing config for buildType release on your build.gradle. Post your app build.gradle if you need further helpAlmanza
Thanks. I posted my build.gradle as requested.Tangy
1: you can modify build version flow below image imageNorthumbrian
Please do not edit solution announcements into the question. Accept (i.e. click the "tick" next to it) one of the existing answer, if there are any. You can also create your own answer, and even accept it, if your solution is not yet covered by an existing answer. Compare stackoverflow.com/help/self-answerFallen
W
19

You can solve this problem by doing any of the following

  1. You need to switch your build variant back to debug you can do this by holding Ctrl+Alt+A on windows or CMD+ALT+A on mac then typing variant in the search bar, select build variant, this would show the build variant option in the left side of your android studio screen then you should select the variant that has debug appended to the name.

  2. If you want to use a release version you need to instruct android studio how to find the keys to sign the apk Add this to your app-level build.gradle file

    apply plugin: 'com.android.application'
    
    android {
     signingConfigs {
        debug {
            storeFile file(var)
            storePassword 'xxx'
            keyAlias = 'xxx'
            keyPassword 'xxx'
        }
        release {
            storeFile file(var)
            storePassword 'xxx'
            keyAlias = 'xxx'
            keyPassword 'xxx'
        }
    }
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.birdersdiary.mobile"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "b1.0"
        testInstrumentationRunner     "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
     }
    
    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    }
    

replace the placeholders with the actual value.

Wilden answered 30/11, 2019 at 1:20 Comment(5)
Thanks oziomajnr; however, since this is my first app, I will need more specifics please, as I don't completely understand your response. I have posted my build.gradle above.Tangy
I modified your build.gradle file @TangyWilden
Your assistance is much appreciated. I believe the problem is in my making clear how all of this build/variant/signing configs are new and vague to me. I haven't a clue. I have made the modifications to my build.gradle as you show above, and the problem still persists. Ctl+Alt+A does nothing. However, Shft+Shft opens the search and I type in 'build variant' and I do get the Build Variants toolbar on the left side. It only shows 'app/release', no debug. So, still stuck in the same place. Problem not resolved. Please assume I know nothing about this stuff.Tangy
There are so many moving parts here that, to the novice, it is mind-boggling.Tangy
yes 1st option worked tool window bar have tab called build variant there we have to select debugMarkley
A
18

You should se the singing config after defining it. Though I guess name it something other than debug if you're going to use it for release:

buildTypes {
        release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

           signingConfig signingConfigs.debug
        }
    }
Almanza answered 30/11, 2019 at 6:24 Comment(5)
thanks, but I need very primitive step-by-step. I am still stuck in the same place. I do not grasp what you are suggesting that I do to solve this problem.Tangy
You have defined the config, but you need to set it. Note that I added a signingConfig line to buildType from your build.gradleAlmanza
Thanks again Rick. And sorry for being so dense. I don't understand these configs at all. I can tell you that I got around this issue just now by randomly trying things and finally under "run/debug configurations" I set "Deploy" from "Default APK" to "APK from app bundle". That problem is gone, but now, while the AVD comes up, it doesn't run/work. Sigh...Tangy
I just need to know how to build a debug apk again and install it on my AVD for testing. That is all I need right now.Tangy
Got it working again. Had to wipe the data of the AVD and do a cold boot. All seems to be working now. Fingers crossed.Tangy
U
6

Please confirm all the below points are fine.

  1. In the left project panel
  • Click on the app and open Open Module Settings
  • Select Module in the let panel and select app
  • In the right panel you can see 3 tabs (Properties, Default Config, and Signing Configs)
  1. In signing Configs check below thinks (if you don not have one, please create new key)
  • set your jks file location in Store File
  • set store password alias and key password as well

enter image description here

  1. In Default Config - just check only application id is correct of yours

  2. Now in the left panel check do below thinks

  • Select Build Variants and scroll down to Signing Config
  • Check you have selected any or please select into $signingConfigs.release

enter image description here

Uttasta answered 24/12, 2021 at 10:13 Comment(0)
P
4

On the left side of android studio, there is Build Variants. Changing from release to debug worked for me.

Build Variants

Platen answered 27/9, 2021 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.