我在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中被设置为调试(而不是发布)(检查构建变量面板)。

如果设置为调试,它应该自动使用自动生成的调试密钥库对应用程序进行签名,而不需要编辑构建脚本。

但是,您将需要创建和配置一个特定的密钥存储库来发布。

官方文档,包括调试和发布模式:https://developer.android.com/tools/publishing/app-signing.html

其他回答

如果你想在调试模式下运行app

1)查看左侧底部,在收藏夹上面有构建变量

2)点击Build variables。单击发布并选择调试

它工作完美!!

在工具窗口栏中选择构建变量 将生成变体从发布更改为调试

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

确保构建变量在Android Studio中被设置为调试(而不是发布)(检查构建变量面板)。

如果设置为调试,它应该自动使用自动生成的调试密钥库对应用程序进行签名,而不需要编辑构建脚本。

但是,您将需要创建和配置一个特定的密钥存储库来发布。

官方文档,包括调试和发布模式:https://developer.android.com/tools/publishing/app-signing.html

始终使用您的构建对您的构建进行签名。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插件用户指南