如何为 beta 版创建 App Bundle 以进行发布?

Posted

技术标签:

【中文标题】如何为 beta 版创建 App Bundle 以进行发布?【英文标题】:How to create App bundle for beta for release? 【发布时间】:2021-12-29 18:42:22 【问题描述】:

在控制台中,我看到了不同版本的应用程序,但我不太明白如何在 android Studio 中创建 App Bundle beta

例如,我尝试以这种方式从 Android Studio 创建:

Build -> Build Bundle(s)/APk -> Build Bundle(s)

问:如何创建测试版?

这是我build.gradle的代码:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'idea'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'realm-android'
apply plugin: 'git-repo'
apply from: './jacoco.gradle'
apply from: "./common-methods.gradle"

android 

    signingConfigs 
        release
    

    packagingOptions 
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.properties'
        exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.xml'
    

    dexOptions 
        javaMaxHeapSize "2048m"
        jumboMode = true
    

    compileOptions 
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    

    kotlinOptions 
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    

    lintOptions 
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    

    defaultConfig 
        applicationId "com.sai.android"
        testApplicationId "com.sai.android.tests"

        multiDexEnabled = true
        vectorDrawables.useSupportLibrary = true

        buildToolsVersion '30.0.2'
        minSdkVersion 19
        compileSdkVersion 30
        targetSdkVersion 30
        versionCode 209
        versionName '2.12.1'

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    

    buildTypes 
        release 
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            lintOptions 
                disable 'MissingTranslation' // google services plugin is causing missing translation issue
            
            testCoverageEnabled false
        
        debug 
            debuggable true
            lintOptions 
                disable 'MissingTranslation' // google services plugin is causing missing translation issue
            
            testCoverageEnabled true
//            applicationIdSuffix ".debug"
        
    

    flavorDimensions "default"

    productFlavors 
        production 
            dimension "default"
        

        staging 
            dimension "default"
        

        acceptance 
            dimension "default"
        
    

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

    bundle 
        language 
            // Specifies that the app bundle should not support configuration APKs for language resources.
            // These resources are instead packaged with each base and dynamic feature APK.
            enableSplit = false
        
    


configurations.all 
    resolutionStrategy 
        force 'com.android.support:support-annotations:29.0.0'
    


dependencies 
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':rasp')
    implementation 'com.saltedge.android.common:views-lib:0.1.8.1@aar'
    implementation 'com.saltedge.android.common:tools-lib:0.1.4@aar'
    implementation 'com.saltedge.android.common:models-lib:0.1.3@aar'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation "androidx.preference:preference-ktx:1.1.1"
    implementation "androidx.work:work-runtime-ktx:2.5.0"
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'com.google.android.gms:play-services-identity:17.0.0'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.1'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.google.firebase:firebase-core:19.0.0'
    implementation 'com.google.firebase:firebase-crashlytics:18.0.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.0'
    implementation('com.twitter.sdk.android:twitter:3.3.0@aar') 
        transitive = true
    
    implementation 'com.tubb.smrv:swipemenu-recyclerview:5.4.8'
    implementation 'org.greenrobot:eventbus:3.2.0'
    implementation 'com.yandex.android:mobmetricalib:3.2.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
    implementation 'net.danlew:android.joda:2.10.2'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    implementation('com.theartofdev.edmodo:android-image-cropper:2.8.0') 
        exclude group: "com.android.support"
    
    implementation 'net.objecthunter:exp4j:0.4.8'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'
    implementation ("com.github.bumptech.glide:glide:4.11.0") 
        exclude group: "com.android.support"
    
    implementation 'com.caverock:androidsvg:1.4'

    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation('androidx.multidex:multidex-instrumentation:2.0.0') 
        exclude group: 'com.android.support', module: 'multidex'
    
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test:rules:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-web:3.3.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', 
        exclude group: 'com.android.support', module: 'support-annotations'
    )
    androidTestImplementation('androidx.test.espresso:espresso-idling-resource:3.1.0', 
        exclude module: 'support-annotations'
    )
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0', 
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    )
    androidTestImplementation 'org.hamcrest:hamcrest-core:2.2'
    androidTestImplementation 'org.hamcrest:hamcrest-integration:1.3'
    androidTestImplementation 'org.hamcrest:hamcrest-library:2.2'
    androidTestImplementation 'com.squareup.okhttp3:mockwebserver:4.3.1'
    androidTestImplementation 'org.mockito:mockito-android:3.2.4'
    testImplementation 'org.mockito:mockito-core:3.3.3'


idea 
    module 
        testOutputDir = file('build/test-classes/debug')
    


repositories 
    mavenCentral()
    maven  url "http://dl.bintray.com/glomadrian/maven" 
    androidCommonGit("https://git.saltedge.com/shared/android-common.git")


setupSigning("./signing.properties", "release")

apply plugin: 'com.google.gms.google-services'

【问题讨论】:

最好先阅读文档:developer.android.com/studio/publish/versioning 【参考方案1】:

您在屏幕截图中显示的版本名称均仅源自您应用模块的build.gradle 文件中的versionName 属性。您将应用放置在哪个 Google Play 商店发布渠道中并不重要。您的 APK / AAB 的版本名称不会改变。

如果您想创建一个带有-beta 后缀的版本,您需要将其实际添加到版本名称值并创建一个 APK/AAB。

Google Play 商店允许您指定自己的版本名称,该名称将显示在商品详情中。您可以在创建版本时执行此操作。但不会影响与APK/AAB打包的实际版本名称。

根据风格或构建类型自动更改版本名称

但是可以根据风格和/或构建类型自动更改versionName(和applicationId)。您可以使用versionNameSuffix 为版本名称添加后缀。例如,如果您想轻松区分示例中列出的生产、登台和验收测试版本,这很有意义。

android
...
    flavorDimensions "default"

    productFlavors 
        production 
            dimension "default"
        

        staging 
            dimension "default"
            versionNameSuffix "-staging"
        

        acceptance 
            dimension "default"
            versionNameSuffix "-acceptance"
        
    

【讨论】:

【参考方案2】:

在您的 gradle 文件中指定 versionName,这里是 docs

【讨论】:

如您所见,我将版本提升至versionName '2.12.1',但我需要在build.gradle 中进行更改,以便在构建 AppBundle 时获得测试版?

以上是关于如何为 beta 版创建 App Bundle 以进行发布?的主要内容,如果未能解决你的问题,请参考以下文章

如何为图像分类中的马赛克增强创建类标签?

如何为现有项目创建 App Clip iOS 14

如何为拆分视图控制器创建启动页面

教你如何为 Mac 版 Chrome 增加启动参数

如何为 Nativescript 捆绑运行 android

如何为 Swift 3 创建第一个视图