Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio does not sign the code for debug build

Tags:

Android Studio refuses to sign my code for debug build.

I have an older project which did not have any signing instructions in build.gradle, so I added these according to this Android gradle signingConfig error and other posts.

My build.gradle file on module level (the only module) looks like this (excerpt):

android {     compileSdkVersion 21     buildToolsVersion '21.1.2'     defaultConfig {         applicationId "cc.appname.android"         minSdkVersion 11         targetSdkVersion 21         versionCode 1         versionName '1.0'     }     signingConfigs {         debug {             storeFile file('../../../.android/debug.keystore')             keyAlias 'androiddebugkey'             keyPassword 'android'             storePassword 'android'         }     }     buildTypes {         debug {             signingConfig signingConfigs.debug         }         release {             minifyEnabled true             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'         }     }     productFlavors {     }     compileOptions {         sourceCompatibility JavaVersion.VERSION_1_7         targetCompatibility JavaVersion.VERSION_1_7     } } 

The storeFile can be found, because when I change the path I get a compile error. When the path is correct, it compiles, but when I try to use the Facebook SDK within my app, it reports a wrong keyhash.

I noticed that signingConfigs

signingConfig signingConfigs.debug 

is underlined with the error message "Cannot infer argument types..."

So I went to Project Settings in the UI, removed signing and the relationship between the build and signing, saved this, and added it back. Same problem.

I am sure this is something very small that I just overlooked, or Google renamed the command between versions, whatever.

Can anybody help?

like image 286
Oliver Hausler Avatar asked Feb 14 '15 05:02

Oliver Hausler


People also ask

Are Android debug builds signed?

Sign your debug build When running or debugging your project from the IDE, Android Studio automatically signs your app with a debug certificate generated by the Android SDK tools. The first time you run or debug your project in Android Studio, the IDE automatically creates the debug keystore and certificate in $HOME/.

What is the password of debug keystore?

The debug keystore is typically located at ~/. android/debug. keystore and its password is android .

What is BuildConfig debug in Android?

In recent versions of the Android Developer Tools (ADT) for Eclipse, there's a class called BuildConfig which is automatically generated by the build. This class is updated automatically by Android's build system (like the R class), and it contains a static final boolean called DEBUG, which is normally set to true.


1 Answers

Several things here, assuming your debug.keystore is the one from the ~/.android folder.

Change this:

    debug {         storeFile file('../../../.android/debug.keystore')         keyAlias 'androiddebugkey'         keyPassword 'android'         storePassword 'android'     } 

to this(store the debug.keystore in the root project):

    debug {         storeFile rootProject.file('debug.keystore')         keyAlias 'androiddebugkey'         keyPassword 'android'         storePassword 'android'     } 

You do not need to override the debug BuildType, it naturally signs with the debug key anyways, so you can remove:

    debug {         signingConfig signingConfigs.debug     } 

The final build.gradle:

android {     compileSdkVersion 21     buildToolsVersion '21.1.2'     defaultConfig {         applicationId "cc.appname.android"         minSdkVersion 11         targetSdkVersion 21         versionCode 1         versionName '1.0'     }     signingConfigs {         debug {             storeFile rootProject.file('debug.keystore')             keyAlias 'androiddebugkey'             keyPassword 'android'             storePassword 'android'         }     }     buildTypes {         release {             minifyEnabled true             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'         }     }     productFlavors {     }     compileOptions {         sourceCompatibility JavaVersion.VERSION_1_7         targetCompatibility JavaVersion.VERSION_1_7     } } 
like image 139
Jared Burrows Avatar answered Oct 02 '22 03:10

Jared Burrows