【问题标题】:Google Play: Bundle was not signedGoogle Play:捆绑包未签名
【发布时间】:2021-11-12 05:44:18
【问题描述】:

我在 Kotlin 中创建应用程序并支付了 Google 开发者帐户。但是上传 .aab 文件存在一些问题:The Android App Bundle was not signed。我在 Stackoverflow 上阅读了所有关于它的主题并尝试了所有解决方案。不适合我。 build.gradle 中的 signingConfig signingConfigs.release 以此错误结尾:Could not get unknown property 'release' for SigningConfig。它仅在我设置signingConfig 时有效。我也在使用这个:minifyEnabled falsedebuggable = false。那么我必须尝试什么? 2021 年有一些新的解决方案吗?!

我的 build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId '...'
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName "1.00"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        manifestPlaceholders["hostName"] = "..."
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig
            debuggable = false
        }
        applicationVariants.all{
            variant ->
                variant.outputs.each{
                    output->
                        def name = "...apk"
                        output.outputFileName = name
                }
        }
    }
    buildFeatures{
        dataBinding = true
        viewBinding = true
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

}

【问题讨论】:

标签: android kotlin build.gradle bundle signed


【解决方案1】:

逐步创建签名aab文件:

  1. 在下一个窗口中选择 Android App Bundle (aab)

  2. 现在您必须创建自己的签名密钥。如果您以后要上传任何更新,则必须使用您在此处创建的签名密钥对其进行签名。

您还需要在build.gradle(app) 中增加版本。

编辑 1:

将:signingConfig 更改为:signingConfig signingConfigs.release 并添加:

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

完整代码:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId '...'
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName "1.00"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        manifestPlaceholders["hostName"] = "..."
    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            debuggable = false
        }
        applicationVariants.all{
            variant ->
                variant.outputs.each{
                    output->
                        def name = "...apk"
                        output.outputFileName = name
                }
        }
    }
    buildFeatures{
        dataBinding = true
        viewBinding = true
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:v1.0.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

}

编辑 2:

我刚刚使用此build.gradle(app) 将项目aab 上传到Google Play:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "pfhb.damian.uploadtest"
        minSdk 28
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

【讨论】:

  • 谢谢,但这正是我正在做的。生成签名包没问题。我试图一次又一次地这样做。但结果还是一样。
  • 答案已更新。
  • Could not get unknown property 'keystoreProperties'。但是下面写的build.gradle 对我有用。上传到 Google Play 仍然无法正常工作。
  • 您是否更改了keyAlias 和其他人的值?
  • 是的。我正在使用key0 和密码123456 进行测试。
【解决方案2】:

您必须创建签名配置版本,希望这会起作用。如果您想知道如何创建此块,请告诉我,我们会更乐意为您提供帮助。

  plugins {
        id 'com.android.application'
        id 'kotlin-android'
        id 'kotlin-android-extensions'
        id 'com.google.gms.google-services'
    }
    
    //repositories { maven { url 'https://maven.cashfree.com/release' } }
    
    android {
        compileSdkVersion 30
        buildToolsVersion "30.0.3"
    
        defaultConfig {
            applicationId "com.xyz.medicine"
            minSdkVersion 27
            targetSdkVersion 30
            versionCode 4
            versionName "1.0"
            multiDexEnabled true
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        // Please check if you have this block or not
    
         signingConfigs {
                release {
                    storeFile file('../secrets/keystore.jks')
                    storePassword 'DUMMYPASSWORD'
                    keyAlias 'DUMMYALIAS'
                    keyPassword 'DUMMYPASSWORD'
                }
            }
    
        buildTypes {
            release {
                resValue "string", "BASE_URL", "https://obhaiyya.com/proMaid/"
                shrinkResources true
                minifyEnabled true
                debuggable false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
            }
            debug {
                shrinkResources false
                minifyEnabled false
                debuggable true
                signingConfig signingConfigs.debug
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = '1.8'
        }
        buildFeatures {
            viewBinding true
            buildFeatures {
                dataBinding true
            }
        }
    
    
    }
    
    dependencies {
    
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        implementation 'androidx.core:core-ktx:1.5.0'
        implementation 'androidx.appcompat:appcompat:1.3.0'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0'
        testImplementation 'junit:junit:4.+'
        androidTestImplementation 'androidx.test.ext:junit:1.1.2'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
        implementation "com.airbnb.android:lottie:3.7.1"
        
    
    }

【讨论】:

  • 是的!这个 build.gradle 用Could not get unknown property 'keystoreProperties' 解决了我的问题。但上传到 Google Play 仍然无法正常工作。
  • 您创建了.jks 文件吗?如果没有,请按照以下步骤操作: 1. 生成密钥库、jks 文件 - 添加所有必要的详细信息,例如名称、状态等 2. 生成 .aab 意味着捆绑 Android 应用程序包。 - 确保在创建此捆绑包之前更改版本代码。让我知道它是否不适用于上述步骤。
  • 是的,我创建了 jks 文件。我用它来签署 apk 以在新的 Android 11 上从文件安装。我尝试创建新项目并创建新的 jks 文件和 aab 文件。 Play Console 中的结果仍然相同。更改版本代码? ? 在哪里?
  • defaultConfig { applicationId "com.obhaiyya.vaidshalahealth" minSdkVersion 27 targetSdkVersion 30 versionCode 4 versionName "1.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 在默认配置块模块 app gradle 版本code : 每次上传新的apk时,版本号加1
  • 我明白了。但这仍然是我的第一次上传。或者不成功的尝试也算作上传?顺便说一句:我昨天换了applicationId
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-28
  • 2022-07-13
  • 2021-11-03
  • 1970-01-01
  • 2015-10-21
  • 2019-12-08
相关资源
最近更新 更多