谷歌应用商店:Bundle未签名。

3
我正在使用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'

}

这个链接有帮助吗 - link - Nitish
谢谢,但这正是我正在做的。 - djlj
你能否在 build.gradle 中添加你所需的构建类型? - Nitish
我编辑了我的原始问题。再次感谢! - djlj
我的问题通过这个链接真正得到了解决:https://developer.android.com/studio/publish/app-signing - “导出加密密钥”是我的解决方案。 - djlj
3个回答

18

当我为发布版本设置“debuggable true”时,我遇到了相同的问题,请确保为发布类型设置“debuggable false”。

buildTypes {
    release {
        minifyEnabled true
        debuggable false

}


1
创建“新密钥库”,签署您的apk并上传。 - Ashwin H
确实,这是我的原因,谢谢!我尝试将其设置为true,因为由于某种原因,debuggable false导致应用程序崩溃。值得一提的是,我还尝试了minifyEnabled false,这也修复了崩溃问题,并且被Play Console接受。 - undefined

1

逐步创建已签名的 aab 文件:

  1. 第一步

  2. 在下一个窗口中选择 Android 应用程序包 (aab)

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

此外,每次更新都需要在 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'
}

谢谢,但这正是我正在做的。生成签名包没问题。我一遍又一遍地尝试着做,但结果仍然是一样的。 - djlj
无法获取未知属性'keystoreProperties'。但是下面的build.gradle对我有效。上传到Google Play仍然无法工作。 - djlj
1
你改变了 keyAlias 和其他值吗? - Damian Piszka
是的。我正在使用“key0”和密码“123456”进行测试。 - djlj
我已成功上传,请查看我的更新答案。 - Damian Piszka
显示剩余3条评论

0

你需要创建签名配置发布,希望这将起作用。如果你想知道如何创建这个区块,我很乐意帮助你。

  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 仍然不起作用。 - djlj
你创建了.jks文件吗?如果没有,请按照以下步骤操作:
  1. 生成密钥库,jks文件
    • 添加所有必要的详细信息,如名称、州等
  2. 生成.aab文件,即Android应用程序包。
    • 在创建此包之前,请确保更改版本代码。
如果以上步骤无法解决问题,请告诉我。
- vijay kumar
是的,我创建了jks文件。我用它来签署apk文件,以便在新的Android 11上从文件安装。我尝试创建新项目并创建新的jks文件和aab文件。Play Console中的结果仍然相同。更改版本代码?在哪里更改? - djlj
默认配置 { 应用程序ID "com.obhaiyya.vaidshalahealth" minSdkVersion 27 targetSdkVersion 30 versionCode 4 versionName "1.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 在默认配置块模块应用 gradle 中 版本代码 : 每次想要上传新的 APK 时,将版本代码增加 1 - vijay kumar
我明白。可这仍然是我的第一次上传。或者说,不成功的尝试也算作上传吗?另外,顺便提一下:我昨天更改了 applicationId - djlj

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接