How to use chrome custom tabs under api 16?

I want to use custom chrome tabs below api 16. My application supports Min SDK Version up to 10 (GingerBread). When I declare a customtabs dependency in the build.gradle file

it gives the following error:

Error: execution completed for task ': app: processDebugManifest'. Failed to merge manifest: uses-sdk: minSdkVersion 10 cannot be less than version 15 declared in the library [com.android.support:customtabs:23.0.1] Suggestion: use tools: overrideLibrary = "android.support.customtabs" to force use of

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

+5
source share
2 answers

Tools: overrideLibrary marker ( see here )

A special token that can only be used with the uses-sdk declaration to override library imports whose minimum SDK version is later than the SDK version for this application. Without such a marker, manifest merging will fail. The token allows users to choose which libraries can be imported, ignoring the minimum version of the SDK.

Example. In android main manifest:

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

allows the library with the following manifest to be imported without errors:

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

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

Be sure to check SDK_INT > ICE_CREAM_SANDWICH_MR1 in your code before making calls to the library to avoid runtime exceptions.

If you are using a system that does not support user-defined tabs, just run the usual ACTION_VIEW intent.

+4
source

Source: https://habr.com/ru/post/1233446/


All Articles