Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook login button click fails when facebook app isn't installed

My facebook login button works alright when the facebook app is installed.

When the facebook app isn't installed on the device, it crashes my app:

E/AndroidRuntime: FATAL EXCEPTION: main                                                                 
java.lang.NoClassDefFoundError: Failed resolution of: 
Landroid/support/customtabs/CustomTabsIntent$Builder;
at com.facebook.internal.CustomTab.openCustomTab(CustomTab.java:47)
at com.facebook.CustomTabMainActivity.onCreate(CustomTabMainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.testapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.testapp-2/lib/arm, /data/app/com.testapp-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.facebook.internal.CustomTab.openCustomTab(CustomTab.java:47) 
at com.facebook.CustomTabMainActivity.onCreate(CustomTabMainActivity.java:67) 
at android.app.Activity.performCreate(Activity.java:6251) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
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) 
Suppressed: java.lang.ClassNotFoundException: android.support.customtabs.CustomTabsIntent$Builder
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

MANIFEST:

<activity
    android:name="com.facebook.CustomTabActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>
</activity>

while fb_login_protocol_scheme value starts with "fb" as needed.

Gradle dependencies:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-database:10.2.1'
    compile 'com.google.firebase:firebase-ads:10.2.1'
    compile ('com.facebook.android:facebook-android-sdk:4.20.0') // app invites
    {
        exclude group: 'com.android.support'
    }
    compile 'com.facebook.android:audience-network-sdk:4.20.0'
    compile "com.android.support:cardview-v7:25.3.0"
    testCompile 'junit:junit:4.12'
}

How can I solve it?

like image 883
Maor Cohen Avatar asked Apr 12 '17 12:04

Maor Cohen


People also ask

Why is my Facebook not letting me log in to my account?

If you can't log into Facebook account, it might because of the following reasons: forgot the Facebook log in details, account hack, Facebook bugs, cache or cookie problems, browser issue, malware/virus infection, the account is disabled by Facebook, etc.

Why Facebook app is not opening?

Try refreshing your browser or reopening the site; on a mobile app, close and reopen the app. You can also check to see if Facebook is offline and then restart your device, update apps, and clear your cache.

Why can't I log out of Facebook on my Android?

Tap the Menu button with your Profile picture in the top right of the screen. Then, scroll down to the bottom and select Log out. This method will log you out of Facebook on your mobile device. To log out of other devices using your phone, tap the Settings wheel from the menu and select Password and Security.

Is there a Facebook Events app?

Using App Events, you can automatically create Custom Audiences based on actions people have taken in your app. You can then target them with relevant ads when they visit Facebook, Instagram and publishers within Audience Network.


1 Answers

You are excluding 'com.android.support' from the facebook dependency. I assume it is because it wasn't including the same version of support libraries as you are (facebook sdk 4.20.0 uses android:support:25.0.0 but you include support libraries 25.3.0, so excluding it is the right thing to do).

But if you want to have the CustomTab feature working, you therefore must include the appropriate dependency in your app dependencies, so add the following line :

compile 'com.android.support:customtabs:25.3.0'

and it should work.

like image 199
PhilippeAuriach Avatar answered Sep 20 '22 18:09

PhilippeAuriach