Search code examples
androidgradlegoogle-play-console

Google Play Console upload error message: cannot declare different versions of Google Play services depending on the device configuration


I'm stuck on a problem when uploading the completed app bundle to the Google Play console. After download, I get this message:
"The app cannot declare different versions of Google Play services depending on the device configuration. The following versions were found: [0, 12451000]"

The app displays a bottom Smart Banner (Google Ads), uses network and apart from algorithmic, it does not do much more.

build.gradle:

ext {
    version = '1.0'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.6.21'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0-alpha09'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle:app:

plugins {
    id 'kotlin-android'
    id 'org.jetbrains.kotlin.kapt'
    id 'com.android.application'
}

android {
    ...
    signingConfigs {
        debug {
            ...
        }
        release {
            ...
        }
    }
    compileSdk 32
    buildToolsVersion '30.0.3'
    defaultConfig {
        minSdk 19
        targetSdk 32
        versionName '1.0'
        versionCode 100
        multiDexEnabled true
        ...
    }

    buildFeatures {
        //noinspection DataBindingWithoutKapt
        dataBinding true
        viewBinding true
    }
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }
        beta {
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
        }
        release {
            applicationIdSuffix ".release"
            versionNameSuffix "-release"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility "11"
        targetCompatibility "11"
    }
    kotlinOptions {
        jvmTarget = "11"
    }
    ndkVersion '25.0.8221429 rc2'
    flavorDimensions "level"
    productFlavors {
        free {
            ...
            dimension "level"
            versionCode 100
            versionName "1.0"
            targetSdk 32
            minSdk 19
            signingConfig signingConfigs.release
        }
        pro {
            ...
            dimension "level"
            versionCode 100
            versionName "1.0"
            targetSdk 32
            minSdk 19
            signingConfig signingConfigs.release
        }
    }
    sourceSets {
        free {
            java { srcDirs 'src/free/java' }
            res { srcDirs 'src/free/res' }
        }
        pro {
            java { srcDirs 'src/pro/java' }
            res { srcDirs 'src/pro/res' }
        }
    }
    lint {
        checkReleaseBuilds false
    }
    dependenciesInfo {
        includeInApk true
        includeInBundle true
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1-native-mt'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1-native-mt'
    implementation 'androidx.appcompat:appcompat:1.6.0-alpha01'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'io.reactivex.rxjava3:rxjava:3.1.4'
    implementation 'com.google.android.gms:play-services-ads:20.6.0'
    implementation 'com.android.support:multidex:1.0.3'
}
task wrapper(type: Wrapper) {
    gradleVersion = '7.3'
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="MissingLeanbackLauncher">

    <!-- Need to listen to UDP datagrams -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <!-- For Android S devices & GMA SDK version 20.3.0 or lower -->
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

    <!-- Support Android TV and do not require a touchscreen -->
    <uses-feature
        android:name="android.software.leanback"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/MyTheme.Blue.SplashScreen">
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="<APP_KEY>" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name=".ActivitySplash"
            android:exported="true"
            android:theme="@style/MyTheme.Blue.SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Preference activity -->
        <activity
            android:name=".ActivityMain"
            android:exported="true"
            android:theme="@style/MyTheme.Blue.SplashScreen">
        </activity>
    </application>

</manifest>

The link related to that problem that I have reviewed:
Different versions of Google Play services cannot be declared depending on the device configuration
The app cannot declare different versions of Google Play services depending on the device configuration
Different versions of Google Play services cannot be declared depending on the device configuration
https://issuetracker.google.com/issues/223240936#comment21
https://issuetracker.google.com/issues/223240936

What I've done:

  • dig into the Gradle documentation to have a better understanding (plugins, implementation). To be honest, I've never done this job as it's always worked with a basic Gradle I just adapted. It was an opportunity to adjust many inconsistencies (may still remain some though).
  • request Google developer support (no answer yet)
  • of course: clean project, invalidate cash

But I'm still totally stuck. I have no clue whatsoever how I can solve this issue.

It's my first post on this forum although intensively exploring the stackoverflow since more than a decade. I've always managed to solve issues by finding solutions on stackoverflow, other forums, docs... until now. All the links above were of no help.

Can anyone help me out? Best regards


Solution

  • Edit: The bug has now been fixed, things should now just work even with 7.3.0-*

    There is currently a bug in Play Console with apps built with Android Gradle plugin 7.3.0-alphaXX. If you revert to 7.2 0 until this is fixed, this should unblock you.