Create android beta apk from build type

441 views Asked by At

I am not able to build beta version APK of my android app. I tried below code

buildTypes {
beta {
    applicationIdSuffix ".beta"
    versionNameSuffix "-beta"
    resValue "string", "appname", "Beta App"
}
release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
 flavorDimensions "default"
 productFlavors {
      free{
          applicationId "com.packagename.free"
        }
      paid{
         applicationId "com.packagename.paid"
       }
}

When I try to generate APK from Genrate Signed APK button, it show error -

com.packagename.free not found

In my app, I am using payu SDK. Please help. Thanks in Advance

1

There are 1 answers

1
Sanwal Singh On BEST ANSWER

You have to below things to build different variants of APK.

  1. Change you app build.gradle like

     buildTypes {
    
     release {
     minifyEnabled true
     shrinkResources true
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     resValue "string", "content_provider", "com.packagename.fileProvider"
    } 
     staging {
     signingConfig signingConfigs.release
     applicationIdSuffix = ".debugStaging"
    }
    dexOptions {
      matchingFallbacks = ['release', 'staging']
     }
    }
    
  2. Now in open you payu build.gradle and add this line in side buildType

    buildTypes {
      release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
     staging {
         }
       }
    
  3. Now you have to create folder under main folder with the same name you gave in buildType "staging"

  4. Now create a new directory inside -main->staging->java and then add your package inside java - com.packagename.debugStaging debugStaging is same as added in staging applicationIdSuffix.

  5. Now repeat step 3 and 4 for your pay SDK folder under main directory with same name as "staging" and under this add java folder and payu package name

  6. Final step- add your beta/staging app with packagename to firebase and download google-services.json file.

Hope this will help you.