7

I develop an Android app using Android Studio and I got the message today that there is a new version of Google Play services and Firebase.

From 10.0.1 to 10.2.0.

I'm using Google play services analytics and ads that's all.

I am already choose an API min 9 and Now I think the ads can't be show in API < 14 .

My build.gradle File:

 apply plugin: 'com.android.application'

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.ilyo.x1application"
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.google.firebase:firebase-ads:10.2.0'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.android.gms:play-services-ads:10.2.0'
    testCompile 'junit:junit:4.12'
}

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

Error Message

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.google.firebase:firebase-ads:10.2.0]

/Users/mac/Documents/AndroidStudioProjects/Project1/app/build/intermediates/exploded-aar/com.google.firebase/firebase-ads/10.2.0/AndroidManifest.xml Suggestion: use tools:overrideLibrary="com.google.firebase.firebase_ads" to force usage

I want to all my ads of my Application can show in all devices, What do you recommend ?

iLyas
  • 1,047
  • 2
  • 13
  • 30
  • 97% of the devices are having sdk version >14. Do you still want min sdk to 9? .It wont bring you much audience and you have to go through a lot of pain by having min sdk to 9 – Manohar Feb 18 '17 at 13:24
  • Thank you Bro, In fact I sill have my phone with API 9 :D – iLyas Feb 18 '17 at 13:27
  • omg which generation are you living in? :) – Manohar Feb 18 '17 at 13:30
  • The culprit is Firebase. upgrade it to 10.2.1 and it will be fixed. // compile 'com.google.firebase:firebase-core:10.2.1' compile 'com.google.firebase:firebase-messaging:10.2.1' compile 'com.google.firebase:firebase-crash:10.2.1' // compile 'com.google.android.gms:play-services-auth:10.2.1' compile 'com.google.android.gms:play-services-maps:10.2.1' compile 'com.google.android.gms:play-services-location:10.2.1' // All those have to be the same version. Plus the minSdkVersion 14 as other have commented. – Pedro Varela Apr 05 '17 at 15:34
  • Thank you for your feedback ;) – iLyas Apr 12 '17 at 00:17

2 Answers2

14

The 10.2.0 version of ALL google related services require a minimum of API version 14. This is a choice done by Google, so they don't have to support API versions below 14.

So you'll have to stick to version 10.0.1 forever if you want to support API versions below 14. Or, you will have to raise your apps minimum API version to 14, and then use the new google services.

Article: https://www.xda-developers.com/google-play-services-release-notes-are-available-for-the-10-2-update-bye-gingerbread/

Moonbloom
  • 7,738
  • 3
  • 26
  • 38
  • Thank you very much, I will choose to support API below 14, but if I choose the version 10.1.0 would I have a problem in the future ? – iLyas Feb 18 '17 at 13:21
  • At some point they will completely give up support for older versions of the google services, at which point you can't use any of them if you continue to use the old google services. But for now, you'll be fine. Remember to accept my answer/upvote if it helped you :) – Moonbloom Feb 18 '17 at 13:25
  • My min sdk is 21, and I keep getting the error. Error:Execution failed for task ':app:processDemoDebugGoogleServices'. > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.0. – Pedro Varela Apr 05 '17 at 15:30
11

Here you can find the official blog post by Google.

Version 10.0.0 of the Google Play services client libraries, as well as the Firebase client libraries for Android, will be the last version of these libraries that support Android API level 9 (Android 2.3, Gingerbread). The next scheduled release of these libraries, version 10.2.0, will increase the minimum supported API level from 9 to 14.

Since you are using:

minSdkVersion 9

you have to change it with:

minSdkVersion 14

Otherwise you can build multiple APKs to support devices with an API level less than 14 using:

productFlavors {
    legacy {
        minSdkVersion 9

    }
    current {
        minSdkVersion 14

    }
}

dependencies {
    legacyCompile 'com.google.android.gms:play-services:10.0.0'
    currentCompile 'com.google.android.gms:play-services:10.2.0'
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841