Failed to start Chrome CustomTabsIntent in my Android app

I am trying to use custom Chrome tabs in an Android app. My MainActivity class extends AppCompatActivity . In onCreate I call startCustomTabs . Below is the code for this:

 private void startCustomTab(){ CustomTabsIntent intent = new CustomTabsIntent.Builder().setToolbarColor(getResources().getColor(R.color.colorPrimary)).build(); intent.launchUrl(this, Uri.parse("http://github.com/black-dragon/SaavnExtractor")); } 

As soon as the application starts, it crashes with the following error:

 11-16 10:55:38.561 30093-30093/com.nick.saavnextractor E/AndroidRuntime: FATAL EXCEPTION: main Process: com.nick.saavnextractor, PID: 30093 java.lang.NoSuchMethodError: No static method startActivity(Landroid/app/Activity;Landroid/content/Intent;Landroid/os/Bundle;)V in class Landroid/support/v4/app/ActivityCompat; or its super classes (declaration of 'android.support.v4.app.ActivityCompat' appears in /data/data/com.nick.saavnextractor/files/instant-run/dex/slice-com.android.support-support-compat-25.0.0_15c83dd4ec129d2d74bfda2e34f6aeeb93d83fa1-classes.dex) at android.support.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:262) at com.nick.saavnextractor.MainActivity.startCustomTab(MainActivity.java:325) at com.nick.saavnextractor.MainActivity.onCreate(MainActivity.java:111) at android.app.Activity.performCreate(Activity.java:6311) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2539) at android.app.ActivityThread.access$900(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5507) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Note. If I run the same code with the same methods in a new application, user tabs start normally.

+7
java android chrome-custom-tabs
source share
2 answers

Ok, so here is the resolution. I used build tools for version 25.0.0, but my SDK platform was 24.

Update build tools, platform tools and SDKs to the same version, and then you will not encounter this problem.

+11
source share

Along with @Nick's answer, I also had to update the Facebook SDK version and the crash stopped.

+3
source share

All Articles