javaandroidgoogle-chromechrome-custom-tabs

How to use chrome custom tabs below api 16?


I want to use chrome custom tabs below api 16. My app suports Min SDK Version upto 10(GingerBread). When I declare the customtabs dependency in build.gradle

it gives the following error :

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 15 declared in library [com.android.support:customtabs:23.0.1] Suggestion: use tools:overrideLibrary="android.support.customtabs" to force usage

How can I implement a mechanism to support devices using SDK below api 16 with default browser and above api 16 with customtabs.


Solution

  • tools:overrideLibrary marker (see here)

    A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version. Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.

    Example, In the main android manifest :

    <uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
    
              tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
    

    will allow the library with the following manifest to be imported without error :

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    
            package="com.example.lib1">
            <uses-sdk android:minSdkVersion="4" />
        </manifest>