Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 344
Anudeep Samaiya Avatar asked Oct 11 '15 01:10

Anudeep Samaiya


2 Answers

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>
like image 67
Anudeep Samaiya Avatar answered Sep 28 '22 23:09

Anudeep Samaiya


As mentioned in the error, you can override the minSdk version from the library by using the tools:overrideLibrary marker.

Be sure to check SDK_INT > ICE_CREAM_SANDWICH_MR1 on your code before making calls to the Library to avoid exceptions at runtime.

When using a system that does not support Custom Tabs, just fire a normal ACTION_VIEW intent.

like image 43
andreban Avatar answered Sep 28 '22 23:09

andreban