In-App billing with gradle productflavors


(Matthieu Smith) #1

I recently imported my project from Eclipse to Android Studio and integrated Gradle’s projectFlavors to support the different environment (DEV, QA and PROD). Although I encountered a problem with my in app billing. It seems to use the package name to query the google store but depending on my productFlavors the package name changes.

my gradle.build definition

apply plugin: 'android'
  android {
    compileSdkVersion 19
    buildToolsVersion '19.0.1'
      defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
    }
      buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
      productFlavors {
        Prod {
            packageName 'com.test.app'
        }
        Qa{
            packageName 'com.test.app.qa'
            versionName '1.2-QA'
        }
        Dev{
            packageName 'com.test.app.dev'
            versionName '1.2-DEV'
        }
    }
}
repositories{
    mavenCentral()
    mavenLocal()
}
  dependencies {
    compile 'com.test.android:infra:1.0@aar'
    compile 'com.android.support:support-v4:+'
    compile 'com.google.android.gms:play-services:4.3.23@aar'
    compile files('libs/adgear-android-sdk.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile project(':libraries:facebook')
}

Thanks for your time.


(Radim Kubacki) #2

It seems to me that your problem is related to Android APIs (in-app billing and how it relates to package name of your application). Your build script declares that different flavors will get different package name and this is done. How this is related to your billing setup is out of Gradle scope.


(Matthieu Smith) #3

Alright thanks i’ll send this to android