Android Studio不签署代码进行调试构建 [英] Android Studio does not sign the code for debug build
问题描述
我有一个较旧的项目,它没有build.gradle中的任何签名指令,因此我添加了这些项目根据此 Android gradle signingConfig错误和其他帖子。
我在模块级别的build.gradle文件(唯一的模块)看起来像这样(摘录):
android {
compileSdkVersion 21
buildToolsVersion '21 .1.2'
defaultConfig {
applicationIdcc.appname.android
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName'1.0'
}
signingConfigs {
debug {
storeFile文件('../../../。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
}
}
可以找到storeFile,因为当我改变路径时,我得到一个编译错误。当路径是正确的,它编译,但是当我尝试在我的应用程序中使用Facebook SDK时,它报告了一个错误的keyhash。
我注意到 signingConfigs
signingConfig signingConfigs.debug
加上错误消息无法推断参数类型...。
所以我去了UI中的项目设置,删除签名以及构建和签名之间的关系,保存此内容并将其添加回来。同样的问题。
我相信这是一个非常小的东西,我只是忽略了,或者谷歌重新命名了版本之间的命令,无论如何。
任何人都可以帮忙吗?
假设您的 debug.keystore
是〜/ .android
文件夹中的一个。
更改:
debug {
storeFile文件('../../../。android / debug.keystore')
keyAlias'androiddebugkey'
keyPassword'android'
storePassword'android'
}
(在根项目中保存 debug.keystore
):
<$ p
storePassword'android'
keyPassword'android'
storeFile rootProject.file('debug.keystore')
keyAlias'androiddebugkey'
}
你不需要重写 debug
BuildType
,它自然会用 debug
键,所以你可以删除:
$ $ p $ debug $ $ b $ signSignConig $ sign
最后 build.gradle
:
android {
compileSdkVersion 21
buildToolsVersion '21 .1.2'
defaultConfig {
applicationIdcc.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
}
}
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?
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
}
}
这篇关于Android Studio不签署代码进行调试构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!