为什么我不断收到错误消息,提示我上传了在调试模式下签名的 APK?

问题描述 投票:0回答:1

“您上传了一个在调试模式下签名的 APK。您需要在发布模式下签名您的 APK”

各位,我想我正在失去它。我第一次尝试将应用程序上传到 Google Play 商店,但我不断收到上述错误消息。

我已按照相关指南生成应用程序的签名发布版本(即,我设置了一个 jks 文件,调整了 build.gradle 文件并通过 key.properties 文件连接了两者)。看起来真的一切都井然有序。请在这里帮助我!

我的配置如下:

我的build.gradle文件在/android/app目录下:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
      keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace "XXX"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "XXX"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 29 
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
}

flutter {
    source '../..'
}

dependencies {}

我的 key.properties 文件在 /android 目录下

storePassword=XXX
keyPassword=XXX
keyAlias=upload
storeFile=upload-keystore_CBT.jks

我的upload-keystore_CBT.jks文件位于/android目录中

我已执行命令

扑扑干净

然后

flutter 构建 appbundle --release

命令运行没有错误,我在 uild pp\outputs undle 中得到一个文件 app-release.aab 按预期释放文件夹。然后我上传到谷歌,在那里我受到了错误的欢迎。

为什么我总是收到此错误?非常感谢!

android flutter debugging release
1个回答
0
投票

根据 Michael 的有用评论,我可以通过将 upload-keystore.jks 文件移动到 android/app 文件夹(而不是 android 文件夹)来运行它。

我遇到了其他问题,因为没有在 Visual Studio 代码中保存所有打开的文件(即修改 build.gradle)并在构建 appbundle/apk 之前运行 flutter clean。

希望这可以帮助其他人避免像我一样花费太多时间......

旁注:总的来说,我发现以下指南最有帮助:https://docs.flutter.dev/deployment/android

在有关此错误的其他帖子中,问题通常是由于未将签名配置从调试更改为发布而导致的(但这不是这里的问题)。

© www.soinside.com 2019 - 2024. All rights reserved.