2017-07-02 215 views
3

我試圖從我的應用程序分享照片到Facebook。我已經添加了Facebook SDK並完成了初始設置。但是,當我運行該應用程序崩潰,我收到以下異常。 這裏是我的logcat:無法獲取提供者com.facebook.internal.FacebookInitProvider:java.lang.ClassNotFoundException

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 

這裏是我的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> 

這裏是我的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:[email protected]' 
    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' 
} 

我可以知道哪裏出了問題來自何處。

+0

show your build.gradle – shmakova

+0

請檢查更新後的問題 –

回答

2

試圖改變你的Facebook的SDK版本到最新版本(現在是4.24.0):

compile 'com.facebook.android:facebook-android-sdk:4.24.0' 
+0

同樣的結果。沒有工作。 –

0

更新您的谷歌播放服務11.0.2

compile 'com.google.android.gms:play-services-maps:11.0.2' 
compile 'com.google.android.gms:play-services-location:11.0.2' 

這個固定這個問題對我來說。

2

我有同樣的錯誤,因爲設置不好multidex。使用Android 4.4.2的設備出現問題。

這我在的build.gradle:

defaultConfig { 
    multiDexEnabled true 
} 

我不得不添加的build.gradle:

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

而且這個方法對我的應用程序類:

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

回答從here原創,當我通過刪除來避免Facebook問題時,我必須解決哪個問題facebook SDK。所以也許可以從那裏幫助另一個小費。

相關問題