[英]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您可以通过执行以下任一操作来解决此问题
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 的变体。
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
}
}
Please confirm all the below points are fine.请确认以下所有点都没有问题。
In Default Config - just check only application id is correct of yours在默认配置中 - 只需检查您的应用程序 ID 是否正确
Now in the left panel check do below thinks现在在左侧面板中检查下面的想法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.