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

JJJones_3860 picture JJJones_3860 · Nov 30, 2019 · Viewed 9.8k times · Source

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.

Answer

oziomajnr picture oziomajnr · Nov 30, 2019

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.