222

I downloaded the zip file of an Android app on github and I'm trying to run it, but I get a dialog with this message

app-release-unsigned.apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.

I'm using Android Studio. What am I supposed to do?

Maarten Bodewes
  • 80,169
  • 13
  • 121
  • 225
andrew
  • 3,539
  • 4
  • 20
  • 40

17 Answers17

475

If anyone wants to debug release build using Android Studio, follow these steps:

  1. Set build variant to release mode.

enter image description here

  1. Right click on app in left navigation pane, click Open Module Settings.

  2. Go to Signing Tab. Add a signing config and fill in information. Select your keychain as well.

enter image description here

  1. Go to Build Type tab. Select release mode and set:

-Debuggable to true.

-Signing Config to the config. (The one you just created).

enter image description here

Sync your gradle. Enjoy!

NightFury
  • 12,692
  • 6
  • 65
  • 112
  • 3
    Should we set Debuggable to false when actually generating the release APK for prod? or will studio do that on its own? – Ishaan Garg Sep 16 '16 at 15:17
  • 8
    @IshaanGarg You should set debuggable to false while making release apk – NightFury Sep 16 '16 at 17:02
  • 1
    You would think it would default to the first one created wonder why it does not... maybe it would be bad for some to sign packages they did not want to sign... but thanks, man I forgot to set the build type "Signing Config" and until the screenshot, I wasn't remembering – CrandellWS Jan 11 '17 at 08:17
  • 15
    there is **NO NEED** to set ***Debuggable*** to ***true***, (unless really intended so). – computingfreak Mar 22 '17 at 06:27
  • 4
    You should be aware though that after setting a config to the build type, all your keys information (including the passwords) will appear in the gradle file... – Jacob.B Apr 09 '17 at 05:43
  • There's an issue with changing signing configs via the Android Studio UI. Or that's what I find. AS updates the gradle.build file, deleting some of the dependencies (which were manually added to gradle.build). If AS shows an error after you update the signing configs, just compare your build.gradle with the previous one in local history. – Christine Jul 02 '17 at 11:21
  • Thank You, so Much, THIS IS THE MOST STYLISH WAY! – Vikas Pandey Mar 31 '18 at 16:12
  • For the last image it helps me to give SHA1 key for release mode. Multiple solution for one comment. thanks – Ahamadullah Saikat Jun 06 '18 at 08:14
  • 1
    "2- Right click on app in left navigation pane, click Open Module Settings." IS NOT WORKING, In case some one facing the same problem you can select "file" -> "Project structure" OR press "Ctrl + Alt + Shift + S" – Yousef Gamal Aug 10 '18 at 14:35
  • it didn't work now it give me the following error : Failed to read key keyAlias from store – has19 Aug 20 '18 at 09:49
  • @has19 Which AS version are you using ? – NightFury Aug 20 '18 at 11:07
  • @NightFury version 3.1.2 – has19 Aug 21 '18 at 11:11
  • Bravo! The only solution worked for me. You guys are amazing. – Raghav Sep 25 '18 at 19:54
102

Make sure the build variant is set to debug (and not release) in Android Studio (check the build variants panel).

If set to debug, it should automatically sign the app with the auto-generated debug keystore, without editing the build scripts.

However you will need to create and configure a specific keystore for release.

Official documentation, covering debug and release modes: https://developer.android.com/tools/publishing/app-signing.html

Stéphane
  • 6,654
  • 2
  • 40
  • 50
58

Always sign your build using your build.gradle DSL script like this:

    android {
    signingConfigs {
        debug {
            storeFile file("debug.keystore")
        }

        myConfig {
            storeFile file("other.keystore")
            storePassword "android"
            keyAlias "androidotherkey"
            keyPassword "android"
        }
    }

    buildTypes {
        bar {
            debuggable true
            jniDebugBuild true
            signingConfig signingConfigs.debug
        }
        foo {
            debuggable false
            jniDebugBuild false
            signingConfig signingConfigs.myConfig
        }
    }
}

If you want to understand a little more of the Gradle build system associated to Android Studio just pay a visit to:

Gradle Plugin User Guide

Martin Revert
  • 3,042
  • 1
  • 27
  • 32
  • But why have I to do that? On the guide they say "By default, there is a debug configuration that is setup to use a debug keystore, with a known password and a default key with a known password.". I don't have any problems with other applications. – andrew Jul 29 '14 at 17:25
  • If your password is ok and debug.keystore is reachable, I don't know. The usual problems I saw in the past with this are file permission or directory permissions. Maybe the project you downloaded is keeping Android Studio local files which points to other debug keystore than yours. In any case your Gradle log must show the path error, please include that log for more help. – Martin Revert Jul 30 '14 at 04:08
  • Hmmm, doesn't work for me either. No gradle errors, but still getting the signing error (and it is pointed at my keyfile). – Brian Knoblauch Dec 02 '14 at 15:25
  • Hi Brian! Could you try to delete your debug.keystore? Then start a new dummy project and a new keystore must to be generated. After that, reopen your actual project and try. It is the only thing I can recommend if anything else commented before fails. – Martin Revert Dec 05 '14 at 20:19
  • 1
    Isn't `debug.keystore` located in `.android` folder? You might want to give full path unless you moved it into your project – Gokhan Arik Dec 29 '16 at 19:36
41

If anyone wants to debug and release separate build variant using Android Studio 3.5, follow the below steps: 1. Set build variant to release mode.

Build Variant

  1. Go to File >> Project Structure
  2. Select Modules, then Signing Config
  3. Click in the Plus icon under Signing Config

Signing Config

  1. Select release section and Provide your release App Information then Apply and OK.

signin

  1. Go to your app level build.gradle and change your buildTypes > "release" section like below Screenshot.

final

Then Run your Project. Happy Coding.

Rafael Tavares
  • 1,417
  • 1
  • 14
  • 27
Shohel Rana
  • 1,891
  • 15
  • 20
37

I was successfully able to debug signed APK , Follow this procedure:-

  1. Choose "release" version in "Build Variant" ToolBar
  2. In the Build.gradle for the module set debuggable true for release build type
  3. Go to File->Project Structure->under signing tab fill all info->Under Flavours tab->Choose signing Config You just created
  4. Set the breakpoints
  5. Run the application in the debug mode
Kevin Panko
  • 7,844
  • 19
  • 46
  • 58
Mohammad Khan
  • 531
  • 5
  • 12
16

signingConfigs should be before buildTypes

signingConfigs {
        debug {
            storeFile file("debug.keystore")
        }

        myConfig {
            storeFile file("other.keystore")
            storePassword "android"
            keyAlias "androidotherkey"
            keyPassword "android"
        }
    }

    buildTypes {
        bar {
            debuggable true
            jniDebugBuild true
            signingConfig signingConfigs.debug
        }
        foo {
            debuggable false
            jniDebugBuild false
            signingConfig signingConfigs.myConfig
        }
    }
NickUnuchek
  • 8,369
  • 9
  • 74
  • 111
13

if you want to run app in debug mode

1) Look at Left Side bottom, above Favorites there is Build Variants

2) Click on Build Variants. Click on release and choose debug

it works perfect !!!

Samir Mangroliya
  • 38,074
  • 16
  • 111
  • 131
13

For gradle Kotlin dsl

signingConfigs {
    create("releaseConfig") {
        storeFile = file("your keystore file path")
        storePassword = "storePassword"
        keyAlias = "keyAlias"
        keyPassword = "keyPassword"
    }
}
buildTypes {
    getByName("release") {
        signingConfig = signingConfigs.getByName("releaseConfig")
        isMinifyEnabled = true
        isShrinkResources = true
        proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
    }
}
Evgenii Vorobei
  • 988
  • 13
  • 17
11

The app project you downloaded may include a signed info in the file of build.gradle. If you saw codes like these:

buildTypes {
    debug {
        signingConfig signingConfigs.release
    }
    release {
        signingConfig signingConfigs.release
    }
}

you could delete them and try again.

Alex Tam
  • 119
  • 1
  • 3
9

My problem was solved by changing the build variant as suggested by Stéphane , if anyone was struggling to find the "Build variants" as I did here is a screenshot where you can find it .

enter image description here

yehyatt
  • 1,848
  • 3
  • 24
  • 28
6

For security reasons, you cannot install an unsigned apk on Android. So if you only have the unsigned apk: you must sign it. Here is how to do that : link

Note that you can sign the apk with a self-signed certificate.

An alternative can be either :

  • to download the signed apk if available.
  • to download the sources, compile them (with Android-Studio or gradle or ...). It will produce multiple apks and one of them will be signed with your debug-key (and so you will be able to install it)
ben75
  • 27,769
  • 7
  • 80
  • 130
  • 1
    I'm not sure I'm understanding. I downloaded the zip of the code of the app and I'm trying to compile it with Android Studio... – andrew Jul 28 '14 at 18:25
  • so you must compile a signed version. Usually the signed version is build at the same time and is located in the same directory as the unsigned one. – ben75 Jul 28 '14 at 18:28
  • If I generate a signed apk it works, but I can't do it every time I have to test the app. I'm missing something here, I just want to try the app as I do with my own applications... – andrew Jul 28 '14 at 18:56
3

How i solved this

This error occurs because you have set your build variants to release mode. set it to build mode and run project again.

If you want to run in release mode, just generate a signed apk the way we do it normally when releasing the app

Benja
  • 81
  • 2
2

In tool window bar select Build Variants Change Build Variant from Release to Debug

Bhaskar Vaddadi
  • 748
  • 4
  • 4
0

My solution was to change the name of my signing config from the default "config" to "debug". To verify, I changed it to some other random name and got the error again, and then changed it back to "debug" and the error was gone. So while it seems artificial and I tend to not believe this is the whole story, give this solution a try.

elliptic1
  • 1,355
  • 1
  • 16
  • 20
0

i also appear this problem,and my code below

        storeFile file(properties.getProperty("filepath"))
        storePassword properties.getProperty("keypassword")
        keyAlias properties.getProperty("keyAlias")
        keyPassword properties.getProperty("keypassword")

the reason is property name error,it should be keyPassword not keypassword

xmliu
  • 213
  • 1
  • 5
0

What finally worked for me, and I have no idea why, is:

  • Went to LastPass (the service I use to keep all my passwords)
  • Select my password by putting the cursor on top of the password and double clicking
  • Once selected I press cmd C to copy
  • Went to Android study and cmd V to paste

Notice I did try to copy many times by selecting the password by clicking at the end of the password and selecting the password by moving the mouse.

It is strange but it only worked by double clicking on top of the password to copy it.

Also I did use the Open Module Settings > Signing... method explained by @NightFury on this post.

slfan
  • 8,209
  • 115
  • 61
  • 73
-1

adding below lines of code in build.gradel file worked for me, add them under buildTypes block below release as shown

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        applicationIdSuffix ".debug"
        debuggable true
    }
Gareema
  • 17
  • 4