Home > Back-end >  Google Play Console upload error message: cannot declare different versions of Google Play services
Google Play Console upload error message: cannot declare different versions of Google Play services

Time:04-27

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

CodePudding user response:

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.

CodePudding user response:

Ok, problem(sssssss) seem solved. The major key was the suggestion of @Pierre on the buggy Android Gradle plugin 7.0.6-alpha06 to replace by com.android.tools.build:gradle:7.2.0-rc01 ( or - Epsilon for the version). It apparently solves the initial issue on the said multiple versions of Google Play when uploading to the Google Play Console.
Most of the time I've lost resides in the Gradle and library includes build.gradle syntax, associated with the obscur error messages. We, as developers, know exactly what libraries we import, what versions we choose and why. Do we? Well, NO, the large majority of us don't (from the developer to the manager), except in precise cases. Our 100% focus is our app: features, images, performance, database, algorithm, customer experience... The IDE and Gradle are just a means to get there, not an objective.
Gradle is that genious tool that does everything, even your morning coffee conceived by brilliant engineers. But it's not end user/developer oriented. I don't want to understand the entire bells and whisles of Gradle, I just want to get through my project development.
I would suggest a set of sample for various types of projects that can be reused and adjusted, rather than those extensive reference docs in which only a couple of items are relevant.
I could say the same for the Google Play Console on which I encounter the following errors:

  1. Version code xxx has already been used. Try another version code.: just increase your code version (integer format)
  2. Your APK or Android App Bundle needs to have the package name xx.xxxxxxx.free.release: you mixed up in the app/variant/flavours prefixes somewhere
  3. Your Android App Bundle is signed with the wrong key.: thrown when uploading several times with different keys. You then have to find out which one the console "chose"...
  4. The Android App Bundle was not signed.: means you try to upload a Debug flagged bundle
  5. The app cannot declare different versions of Google Play services depending on the device configuration. The following versions were found: [0, 12451000]: bug in gradle 7.0.6-alpha06 library Again, many thank's to @Pierre both for getting me through.
  • Related