我在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。 我该怎么办?


当前回答

用于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")
    }
}

其他回答

始终使用您的构建对您的构建进行签名。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构建系统,请访问:

Gradle插件用户指南

如果有人想使用Android Studio调试发布版本,请遵循以下步骤:

将构建变体设置为发布模式。

右键单击左侧导航窗格中的应用程序,单击打开模块设置。 进入签名标签。添加签名配置并填写信息。选择你的钥匙链。

转到构建类型选项卡。选择释放模式并设置:

-可调试为true。

-将Config签名到Config。(你刚创建的那个)。

同步你的gradle。享受吧!

我的解决方案是将签名配置的名称从默认的“config”更改为“debug”。为了验证,我将其更改为其他一些随机名称并再次得到错误,然后将其更改为“调试”,错误就消失了。所以,虽然这看起来是人为的,我倾向于不相信这是全部的故事,尝试一下这个解决方案。

我也出现了这个问题,下面是我的代码

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

原因是属性名错误,它应该是keyPassword而不是keyPassword

我是怎么解决的

发生此错误是因为您已将构建变量设置为发布模式。将其设置为构建模式并再次运行项目。

如果你想在发布模式下运行,只需生成一个签名的apk,就像我们在发布应用程序时通常做的那样