简体   繁体   English

Android Studio 3.5.2 - 错误:您当前选择的变体 (app-release-unsigned.apk) 的 apk 未签名

[英]Android Studio 3.5.2 - Error: The apk for your currently selected variant (app-release-unsigned.apk) is not signed

A little background.一点背景。 I have been building/debugging/testing my simple App for a few months with no problems.几个月来,我一直在构建/调试/测试我的简单应用程序,没有任何问题。 Build/install on AVD or my actual S9 phone.在 AVD 或我的实际 S9 手机上构建/安装。 All worked just fine for months.几个月来一切都很好。 Now, ready for my first beta release to the Play Store (my first app ever).现在,准备好在 Play 商店发布我的第一个测试版(我的第一个应用程序)。 So, I followed instructions on 'signing' my app.因此,我按照“签署”我的应用程序的说明进行操作。 That worked and I uploaded my app bundle to the Play Store.那行得通,我将我的应用程序包上传到了 Play 商店。 Now I can't build/debug/install at all in Android Studio anymore.现在我根本无法在 Android Studio 中构建/调试/安装。

Error: The apk for your currently selected variant (app-release-unsigned.apk) is not signed.错误:您当前选择的变体 (app-release-unsigned.apk) 的 apk 未签名。 Please specify a signing configuration for this variant (release).请为此变体(发行版)指定签名配置。

在此处输入图片说明

Debug (Shift+F9) produces the above error and shows the "Edit configuration" dialog.调试 (Shift+F9) 产生上述错误并显示“编辑配置”对话框。

在此处输入图片说明

I click on the "Fix" button and from there I have no idea what to do.我点击“修复”按钮,然后我不知道该怎么做。 Or how to use these different build configurations.或者如何使用这些不同的构建配置。

在此处输入图片说明

build.gradle构建.gradle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        debug {
            storeFile file(var)
            storePassword 'xxx'
            keyAlias = 'xxx'
            keyPassword 'xxx'
        }
    }
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.birdersdiary.mobile"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "b1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Once I click on the "FIX" button I am taken to the "Run/Debug Configurations" dialog.单击“FIX”按钮后,我将进入“运行/调试配置”对话框。 And from there it is completely oblivious to me what needs to happen in order to Fix the problem.从那里开始,我完全不知道需要做什么才能解决问题。

Any assistance greatly appreciated.非常感谢任何帮助。

You can solve this problem by doing any of the following您可以通过执行以下任一操作来解决此问题

  1. You need to switch your build variant back to debug you can do this by holding Ctrl+Alt+A on windows or CMD+ALT+A on mac then typing variant in the search bar, select build variant , this would show the build variant option in the left side of your android studio screen then you should select the variant that has debug appended to the name.您需要将您的构建变体切换回调试您可以通过在 Windows 上按住 Ctrl+Alt+A 或在 Mac 上按住 CMD+ALT+A 然后在搜索栏中键入variant来实现此操作,选择build variant ,这将显示构建变体选项在您的 android studio 屏幕的左侧,您应该选择在名称中附加了 debug 的变体。

  2. If you want to use a release version you need to instruct android studio how to find the keys to sign the apk Add this to your app-level build.gradle file如果您想使用发布版本,您需要指示 android studio 如何找到对 apk 进行签名的密钥 将此添加到您的应用程序级build.gradle文件中

    apply plugin: 'com.android.application' android { signingConfigs { debug { storeFile file(var) storePassword 'xxx' keyAlias = 'xxx' keyPassword 'xxx' } release { storeFile file(var) storePassword 'xxx' keyAlias = 'xxx' keyPassword 'xxx' } } compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig { applicationId "com.birdersdiary.mobile" minSdkVersion 15 targetSdkVersion 29 versionCode 1 versionName "b1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.preference:preference:1.1.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }

replace the placeholders with the actual value.用实际值替换占位符。

You should se the singing config after defining it.你应该在定义它之后设置唱歌配置。 Though I guess name it something other than debug if you're going to use it for release:虽然我想如果您打算将其用于发布,请将其命名为 debug 以外的其他名称:

buildTypes {
        release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

           signingConfig signingConfigs.debug
        }
    }

On the left side of android studio, there is Build Variants .在 android studio 的左侧,有Build Variants Changing from release to debug worked for me.release更改为debug对我有用。

构建变体

Please confirm all the below points are fine.请确认以下所有点都没有问题。

  1. In the left project panel在左侧项目面板中
  • Click on the app and open Open Module Settings单击应用程序并打开打开模块设置
  • Select Module in the let panel and select app在 let 面板中选择Module并选择app
  • In the right panel you can see 3 tabs (Properties, Default Config, and Signing Configs)在右侧面板中,您可以看到 3 个选项卡(属性、默认配置和签名配置)
  1. In signing Configs check below thinks (if you don not have one, please create new key)在签名配置检查下面认为(如果你没有,请创建新密钥)
  • set your jks file location in Store File在 Store File 中设置您的 jks 文件位置
  • set store password alias and key password as well设置存储密码别名和密钥密码

在此处输入图片说明

  1. In Default Config - just check only application id is correct of yours在默认配置中 - 只需检查您的应用程序 ID 是否正确

  2. Now in the left panel check do below thinks现在在左侧面板中检查下面的想法

  • Select Build Variants and scroll down to Signing Config选择构建变体并向下滚动到签名配置
  • Check you have selected any or please select into $signingConfigs.release检查您是否选择了任何或请选择进入$signingConfigs.release

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 app-release-unsigned.apk 未签名 - app-release-unsigned.apk is not signed Cordova app-release-unsigned.apk 不工作 - Cordova app-release-unsigned.apk not working 不能通过g-mail在Android手机上打开文件(来自Android Studio的app-release-unsigned.apk)的原因是什么? - What could be the reason a file (app-release-unsigned.apk from Android Studio) does not open on an android phone from g-mail? 错误:您当前选择的变体(未知输出)的 apk 未签名。 请为此变体指定签名配置(调试) - Error: The apk for your currently selected variant (Unknown output) is not signed. Please specify a signing configuration for this variant (debug) jarsigner:无法打开 jar 文件:app-release-unsigned.apk - jarsigner: unable to open jar file: app-release-unsigned.apk android studio错误:app-release-unsgined.apk未签名 - android studio error: app-release-unsgined.apk is not signed 使用Android Studio生成未签名的发布APK - Generate unsigned release APK with Android Studio 使用 Android Studio 生成未签名的发布 apk - Generating unsigned, release apk with Android Studio Android Studio:解析签名版本时出错APK - Android Studio: error while parsing signed release APK 无法在Android Studio上发布签名的APK - failed to release a signed APK on Android Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM