Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get provider com.facebook.internal.FacebookInitProvider: java.lang.ClassNotFoundException

I am trying to share a photo from my application to facebook. I have added the Facebook SDK and done the initial setup. But when I run the application its crashing and I am getting the following exception.

Here is my logcat:

java.lang.RuntimeException: Unable to get provider com.facebook.internal.FacebookInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.facebook.internal.FacebookInitProvider" on path: DexPathList[[zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk", zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk"],nativeLibraryDirectories=[/data/app/com.ignite.a01hw909350.kolamdemo-2/lib/arm64, /data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk!/lib/arm64-v8a, /data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
       at android.app.ActivityThread.installProvider(ActivityThread.java:5267)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:4859)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4799)
       at android.app.ActivityThread.access$1600(ActivityThread.java:168)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1434)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5609)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.internal.FacebookInitProvider" on path: DexPathList[[zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk", zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk"],nativeLibraryDirectories=[/data/app/com.ignite.a01hw909350.kolamdemo-2/lib/arm64, /data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk!/lib/arm64-v8a, /data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
       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 android.app.ActivityThread.installProvider(ActivityThread.java:5252)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:4859) 
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4799) 
       at android.app.ActivityThread.access$1600(ActivityThread.java:168) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1434) 
       at android.os.Handler.dispatchMessage(Handler.java:102) 
       at android.os.Looper.loop(Looper.java:148) 
       at android.app.ActivityThread.main(ActivityThread.java:5609) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 
    Suppressed: java.lang.ClassNotFoundException: com.facebook.internal.FacebookInitProvider
       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)
            ... 12 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Here is my Manifest.xml

<application
        android:name=".AppController"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
        <activity android:name=".MainActivity" />
        <activity
            android:name=".ARCameraActivity"
            android:configChanges="orientation|screenSize"
            android:screenOrientation="fullSensor" />
        <activity
            android:name=".RegistrationActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".LoginActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".SplashActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MenuActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".ScanAndDrawActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".GalleryActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".PdfKolamActivity"
            android:screenOrientation="portrait" />

        <service
            android:name=".BluetoothService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.ignite.a01hw909350.kolamdemo.BluetoothService" />
            </intent-filter>
        </service>

        <receiver
            android:name=".MyScheduleReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".BotDialogActivity"
            android:launchMode="singleInstance"
            android:noHistory="true"
            android:theme="@style/Theme.AppCompat.Light.Translucent" />
        <activity android:name=".ModelActivity" />
        <activity android:name=".PanchangActivity" />

        <receiver
            android:name=".MyStartServiceReceiver" android:exported="true"/>

        <service
            android:name=".services.AlarmService"
            android:enabled="true">
            <intent-filter>
                <action android:name="NOTIFICATION_SERVICE" />
            </intent-filter>
        </service>

        <receiver
            android:name=".BootReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
        </receiver>
        <provider android:authorities="com.facebook.app.FacebookContentProvider43234236033829"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>
    </application>

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.ignite.a01hw909350.kolamdemo"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    aaptOptions {
        noCompress 'KARMarker'
        noCompress 'armodel'
    }
    repositories {
        jcenter()
        maven()
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':KudanAR1')
    compile project(':eventbus-3.0.0')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.scottyab:secure-preferences-lib:0.1.4'
    compile 'com.jrummyapps:animated-svg-view:1.0.1'
    compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
    compile 'io.palaima:smoothbluetooth:0.1.0'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.afollestad.material-dialogs:core:0.9.3.0'
    compile 'com.flurgle:camerakit:0.9.13'
    compile 'com.github.zhukic:sectioned-recyclerview:1.0.0'
    compile 'com.android.support:support-vector-drawable:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.prolificinteractive:material-calendarview:1.4.3'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:design:25.3.1'
    compile 'com.github.barteksc:android-pdf-viewer:2.4.0'
    compile 'org.rajawali3d:rajawali:1.1.668@aar'
    compile 'com.tapadoo.android:alerter:1.0.8'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    testCompile 'junit:junit:4.12'
}

Where is the problem coming from?

like image 959
Sagar Suri Avatar asked Jul 02 '17 04:07

Sagar Suri


2 Answers

I had the same error because a badly set multidex. The problem occurred on device with Android 4.4.2.

This i had in build.gradle:

defaultConfig {
    multiDexEnabled true
}

And I had to add to build.gradle:

dependencies {
    compile 'com.android.support:multidex:1.0.2'
}

And this method to my application class:

protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

Answer is originaly from here, which problem I had to solve when I avoided facebook problem by removing facebook SDK. So maybe can help another tip from there.

like image 87
jirimertin Avatar answered Nov 17 '22 07:11

jirimertin


Try to change your facebook-sdk version to the latest (now it is 4.24.0):

compile 'com.facebook.android:facebook-android-sdk:4.24.0'
like image 2
shmakova Avatar answered Nov 17 '22 09:11

shmakova