web-dev-qa-db-ja.com

Android Facebook SDKをプロジェクトに追加した後のjava.lang.noclassDeffoundErrorとclassNotFoundException

Android Facebook SDKをProjectに追加しました。

これがログです

_E/AndroidRuntime: FATAL EXCEPTION: main
    Process: www.pro_cs_is.com, PID: 20307
    Java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/appevents/InternalAppEventsLogger;
        at com.facebook.marketing.internal.MarketingLogger.<init>(MarketingLogger.Java:47)
        at com.facebook.marketing.internal.MarketingInitProvider.setupCodeless(MarketingInitProvider.Java:68)
        at com.facebook.marketing.internal.MarketingInitProvider.onCreate(MarketingInitProvider.Java:49)
        at Android.content.ContentProvider.attachInfo(ContentProvider.Java:1927)
        at Android.content.ContentProvider.attachInfo(ContentProvider.Java:1902)
        at Android.app.ActivityThread.installProvider(ActivityThread.Java:6528)
        at Android.app.ActivityThread.installContentProviders(ActivityThread.Java:6021)
        at Android.app.ActivityThread.handleBindApplication(ActivityThread.Java:5927)
        at Android.app.ActivityThread.access$1200(ActivityThread.Java:200)
        at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1673)
        at Android.os.Handler.dispatchMessage(Handler.Java:106)
        at Android.os.Looper.loop(Looper.Java:201)
        at Android.app.ActivityThread.main(ActivityThread.Java:6806)
        at Java.lang.reflect.Method.invoke(Native Method)
        at com.Android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.Java:547)
        at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:873)
     Caused by: Java.lang.ClassNotFoundException: Didn't find class "com.facebook.appevents.InternalAppEventsLogger" on path: DexPathList[[Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/base.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_dependencies_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_resources_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_0_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_1_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_2_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_3_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_4_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_5_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_6_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_7_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_8_apk.apk", Zip file "/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.Java:134)
        at Java.lang.ClassLoader.loadClass(ClassLoader.Java:379)
        at Java.lang.ClassLoader.loadClass(ClassLoader.Java:312)
        at com.facebook.marketing.internal.MarketingLogger.<init>(MarketingLogger.Java:47) 
        at com.facebook.marketing.internal.MarketingInitProvider.setupCodeless(MarketingInitProvider.Java:68) 
        at com.facebook.marketing.internal.MarketingInitProvider.onCreate(MarketingInitProvider.Java:49) 
        at Android.content.ContentProvider.attachInfo(ContentProvider.Java:1927) 
        at Android.content.ContentProvider.attachInfo(ContentProvider.Java:1902) 
        at Android.app.ActivityThread.installProvider(ActivityThread.Java:6528) 
        at Android.app.ActivityThread.installContentProviders(ActivityThread.Java:6021) 
        at Android.app.ActivityThread.handleBindApplication(ActivityThread.Java:5927) 
        at Android.app.ActivityThread.access$1200(ActivityThread.Java:200) 
        at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1673) 
        at Android.os.Handler.dispatchMessage(Handler.Java:106) 
        at Android.os.Looper.loop(Looper.Java:201) 
        at Android.app.ActivityThread.main(ActivityThread.Java:6806) 
        at Java.lang.reflect.Method.invoke(Native Method) 
        at com.Android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.Java:547) 
        at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:873) 
        Suppressed: Java.io.IOException: No original dex files found for dex location /data/app/www.pro_cs_is.com-ewD1U225Ajh1l9uikBkdWg==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.Java:354)
        at dalvik.system.DexFile.<init>(DexFile.Java:101)
        at dalvik.system.DexFile.<init>(DexFile.Java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.Java:394)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.Java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.Java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.Java:74)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.Java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.Java:64)
        at com.Android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.Java:73)
        at com.Android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.Java:88)
E/AndroidRuntime:     at Android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.Java:74)
        at Android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.Java:40)
        at Android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.Java:729)
        at Android.app.LoadedApk.getClassLoader(LoadedApk.Java:812)
        at Android.app.LoadedApk.getResources(LoadedApk.Java:1034)
        at Android.app.ContextImpl.createAppContext(ContextImpl.Java:2357)
        at Android.app.ActivityThread.handleBindApplication(ActivityThread.Java:5817)
                ... 8 more
_

build.gradle(モジュール:アプリ)

_apply plugin: 'com.Android.application'

Android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "test.com.app"
        minSdkVersion 15
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            useProguard true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.Android.material:material:1.1.0-alpha05'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.5.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0-alpha03'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
        exclude group: 'com.google.code.findbugs'
    })
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'org.jsoup:jsoup:1.11.3'
    implementation 'com.google.apis:google-api-services-blogger:v3-rev57-1.23.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'org.Apache.commons:commons-lang3:3.8.1'
    implementation 'com.github.ybq:Android-SpinKit:1.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation('com.crashlytics.sdk.Android:crashlytics:2.9.8@aar') {
        transitive = true
    }

    implementation 'androidx.multidex:multidex:2.0.1'
    configurations {
        all*.exclude group: 'com.google.guava', module: 'listenablefuture'
    }
    implementation 'com.Android.support:customtabs:28.3.0'
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
    implementation 'com.github.seventhmoon:ipapi-retrofit:1.44'
    implementation 'com.google.firebase:firebase-ads:17.2.0'
    implementation 'com.google.Android.ads.consent:consent-library:1.0.7'
    implementation 'com.facebook.Android:facebook-Android-sdk:4.42.0'
    implementation 'com.facebook.Android:facebook-core:4.42.0'
    implementation 'com.facebook.Android:facebook-marketing:4.42.0'

}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

_

AndroidManifestファイルのメタデータ

_ <meta-data Android:name="com.facebook.sdk.ApplicationId"
            Android:value="@string/facebook_app_id"/>
_

以前のバージョンのFacebook SDKを追加しようとしましたが、これもうまくいきませんでした

_implementation 'com.facebook.Android:facebook-Android-sdk:[4,5
_

Proguard Facebook Rules

_# Facebook
-keep class com.facebook.** {*;}
-dontwarn com.facebook.**
_
8
Dr Mido

Build.gradleファイルを追加してみてください、

repositories {
    mavenCentral()
}
 _

ファイル - >キャッシュの無効化と再起動 - >無効化と再起動にも行うこともできます。

0
dcanh121