2

I created a login app with facebook. When I click login button it shows this error.

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.myapp.test, PID: 16970
                  java.lang.NoSuchMethodError: android.support.v4.app.ActivityCompat.startActivity
                      at android.support.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:200)
                      at com.facebook.internal.CustomTab.openCustomTab(CustomTab.java:48)
                      at com.facebook.CustomTabMainActivity.onCreate(CustomTabMainActivity.java:67)
                      at android.app.Activity.performCreate(Activity.java:5299)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
                      at android.app.ActivityThread.access$800(ActivityThread.java:138)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5061)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
                      at dalvik.system.NativeStart.main(Native Method)

I have check dependencies in build.gradle, I have AppCompat library

compile 'com.android.support:appcompat-v7:25.0.1'

I think it is the latest.

Did anyone ever seen this? Please help.

I have read this : https://stackoverflow.com/a/39300065/5241603 Not help.

Community
  • 1
  • 1
K.Sopheak
  • 22,904
  • 4
  • 33
  • 78

3 Answers3

4

Don't know if it helps you but in my case (I have Facebook SDK in my app with custom tabs enabled) this error happened when user (without installed Facebook app) tried to log in.

Exception java.lang.NoSuchMethodError: No virtual method launchUrl(Landroid/app/Activity;Landroid/net/Uri;)V in class Landroid/support/customtabs/CustomTabsIntent; or its super classes 
com.facebook.internal.CustomTab.openCustomTab (CustomTab.java:48)

Updating dependency to use latest SDK version (they switched to customtabs:25.0.0 in version 4.17.0)

compile 'com.facebook.android:facebook-android-sdk:4.17.0'

fixed the problem.

I also use Custom Tabs (v25.0.0) in my app and have no issues with them. If it's not your case you can check what they've changed.

Answer by mat

Community
  • 1
  • 1
Bugs Happen
  • 2,169
  • 4
  • 33
  • 59
1

Using

compile 'com.facebook.android:facebook-android-sdk:4.20.0'
compile 'com.android.support:customtabs:25.2.0'

solved the problem for me

Mohammad
  • 1,185
  • 1
  • 14
  • 26
0

In your stack trace, it appears that you are using a v4 ActivityCompat with an import of v7 ActivityCompat. Try checking the imports in the ActivityCompat class that is to be launched, and make sure you are using the proper version (7, not 4).