[英]app-release-unsigned.apk is not signed
我在 github 上下载了一个 Android 应用程序的 zip 文件,我正在尝试运行它,但我收到了一个带有此消息的对话框
app-release-unsigned.apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.
我正在使用 Android Studio。 我应该做些什么?
确保在 Android Studio 中将构建变体设置为debug (而不是release )(检查构建变体面板)。
如果设置为调试,它应该使用自动生成的调试密钥库自动签署应用程序,而无需编辑构建脚本。
但是,您需要为发布创建和配置特定的密钥库。
官方文档,涵盖调试和发布模式:https ://developer.android.com/tools/publishing/app-signing.html
始终使用 build.gradle DSL 脚本对您的构建进行签名,如下所示:
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
}
}
}
如果您想了解更多与 Android Studio 相关的 Gradle 构建系统,只需访问:
我成功调试了已签名的 APK,请按照以下步骤操作:-
Build.gradle
中为发布构建类型设置debuggable true
signingConfigs 应该在 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
}
}
对于 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")
}
}
如果你想在调试模式下运行应用程序
1)查看左侧底部,在收藏夹上方有构建变体
2) 单击构建变体。 点击发布并选择调试
它工作完美!
您下载的应用项目可能在 build.gradle 文件中包含签名信息。 如果你看到这样的代码:
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
}
}
你可以删除它们然后再试一次。
出于安全原因,您不能在 Android 上安装未签名的 apk。 因此,如果您只有未签名的 apk:您必须对其进行签名。 这是如何做到的: 链接
请注意,您可以使用自签名证书对 apk 进行签名。
另一种选择可以是:
我是如何解决这个问题的
发生此错误是因为您已将构建变体设置为发布模式。 将其设置为构建模式并再次运行项目。
如果你想在发布模式下运行,只需按照我们发布应用程序时通常的方式生成一个签名的apk
在工具窗口栏中选择 Build Variants Change Build Variant from Release to Debug
我的解决方案是将我的签名配置的名称从默认的“配置”更改为“调试”。 为了验证,我将其更改为其他一些随机名称并再次出现错误,然后将其更改回“调试”并且错误消失了。 因此,虽然它看起来很人为,而且我倾向于不相信这是整个故事,但请尝试使用此解决方案。
我也出现这个问题,下面是我的代码
storeFile file(properties.getProperty("filepath"))
storePassword properties.getProperty("keypassword")
keyAlias properties.getProperty("keyAlias")
keyPassword properties.getProperty("keypassword")
原因是属性名错误,应该是keyPassword而不是keypassword
最终对我有用的,我不知道为什么,是:
请注意,我确实尝试通过单击密码末尾并通过移动鼠标选择密码来选择密码来进行多次复制。
这很奇怪,但它只能通过双击密码顶部来复制它。
我也确实使用了@NightFury 在这篇文章中解释的 Open Module Settings > Signing... 方法。
在 build.gradel 文件中添加以下代码行对我有用,将它们添加到 release 下面的 buildTypes 块下,如图所示
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
debuggable true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.