Android Studio 不对调试构建的代码进行签名 [英] Android Studio does not sign the code for debug build
问题描述
Android Studio 拒绝签署我的调试版本代码.
Android Studio refuses to sign my code for debug build.
我有一个较旧的项目,它在 build.gradle 中没有任何签名说明,所以我根据此添加了这些 Android gradle 签名配置错误 和其他帖子.
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.
我在模块级别(唯一的模块)上的 build.gradle 文件看起来像这样(摘录):
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
}
}
可以找到storeFile,因为当我更改路径时会出现编译错误.当路径正确时,它会编译,但是当我尝试在我的应用程序中使用 Facebook SDK 时,它会报告错误的 keyhash.
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.
我注意到signingConfigs
signingConfig signingConfigs.debug
带有下划线的错误消息无法推断参数类型..."
is underlined with the error message "Cannot infer argument types..."
所以我转到了 UI 中的项目设置,删除了签名以及构建和签名之间的关系,保存了它,然后重新添加了它.同样的问题.
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.
有人可以帮忙吗?
推荐答案
这里有几件事,假设您的 debug.keystore
是 ~/.android
文件夹中的那一项.
Several things here, assuming your debug.keystore
is the one from the ~/.android
folder.
改变这个:
debug {
storeFile file('../../../.android/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
到这个(在根项目中存储debug.keystore
):
to this(store the debug.keystore
in the root project):
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
你不需要覆盖 debug
BuildType
,它自然地用 debug
键签名,所以你可以删除:>
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
}
最终的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屋!