Android

java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.ads.MobileAdsInitProvider”

java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.ads.MobileAdsInitProvider” on path: DexPathList[[zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/base.apk”, zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/split_lib_resources_apk.apk”, zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/split_lib_slice_0_apk.apk”],nativeLibraryDirectories=[/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/lib/arm64, /system/lib64, /vendor/lib64]]

at android.app.ActivityThread.installProvider(ActivityThread.java:6501)

at android.app.ActivityThread.installContentProviders(ActivityThread.java:6064)

at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5968)

at android.app.ActivityThread.-wrap1(Unknown Source:0)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1684)

at android.os.Handler.dispatchMessage(Handler.java:105)

at android.os.Looper.loop(Looper.java:164)

at android.app.ActivityThread.main(ActivityThread.java:6759)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.ads.MobileAdsInitProvider” on path: DexPathList[[zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/base.apk”, zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/split_lib_resources_apk.apk”, zip file “/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/split_lib_slice_0_apk.apk”],nativeLibraryDirectories=[/data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/lib/arm64, /system/lib64, /vendor/lib64]]

at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)

at java.lang.ClassLoader.loadClass(ClassLoader.java:379)

at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

at android.app.ActivityThread.installProvider(ActivityThread.java:6486)

at android.app.ActivityThread.installContentProviders(ActivityThread.java:6064)

at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5968)

at android.app.ActivityThread.-wrap1(Unknown Source:0)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1684)

at android.os.Handler.dispatchMessage(Handler.java:105)

at android.os.Looper.loop(Looper.java:164)

at android.app.ActivityThread.main(ActivityThread.java:6759)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

Suppressed: java.io.IOException: No original dex files found for dex location /data/app/ddolcatmaster.finedustrecord-I9sX3NnW8Ncpg-N3_bqEDw==/split_lib_resources_apk.apk

at dalvik.system.DexFile.openDexFileNative(Native Method)

at dalvik.system.DexFile.openDexFile(DexFile.java:353)

at dalvik.system.DexFile.<init>(DexFile.java:100)

at dalvik.system.DexFile.<init>(DexFile.java:74)

at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)

at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)

at dalvik.system.DexPathList.<init>(DexPathList.java:157)

at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)

at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)

at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:46)

at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)

at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)

at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:736)

at android.app.LoadedApk.getClassLoader(LoadedApk.java:769)

at android.app.LoadedApk.getResources(LoadedApk.java:996)

at android.app.ContextImpl.createAppContext(ContextImpl.java:2243)

at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5868)

… 8 more

 

 

오류가 발생했을 때 build.gradle 파일이다.

 

 

apply plugin: 'com.android.application'

apply plugin: 'io.fabric'

android {
compileSdkVersion 26
defaultConfig {
applicationId "test"
minSdkVersion 19
targetSdkVersion 26
versionCode 7
versionName "1.0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.google.firebase:firebase-ads:17.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-crash:16.2.1'

implementation 'im.dacer:AndroidCharts:1.0.4' //https://github.com/HackPlan/AndroidCharts

implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
}

apply plugin: 'com.google.gms.google-services'

자바에서는 소스코드를 가지고 dex 파일을 생성한다.

하나의 dex 파일에 함수의 개수가 65536개로 제한되어 있어 발생하는 문제였다.

 

1. build.gradle 파일에 multiDexEnabled true를 추가한다.

defaultConfig {
      multiDexEnabled true
}

 

2. dependencies에 com.android.support:multidex를 추가한다.

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    //implementation 'com.android.support:appcompat-v7:27.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.google.firebase:firebase-ads:17.0.0'
    //implementation 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-crash:16.2.1'


    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }


}

 

3.AndroidManifest.xml파일에 Application을 추가합니다.

<application
android:name=".TestApplication"
android:allowBackup="false"
android:fullBackupOnly="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

 

public class TestApplication extends Application {
    private boolean DEBUGGABLE = false;
    public TestApplication() {
        super();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        try {
            MultiDex.install(this);
        }catch (Exception e){
            Crashlytics.logException(new CustomException("MultiDex.install() 오류 발생"));
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();

        initFabric();

        try {
            PackageInfo info  = getPackageManager().getPackageInfo(getPackageName(), 0);
            int flags = info.applicationInfo.flags;
            DEBUGGABLE = (0 != (flags & ApplicationInfo.FLAG_DEBUGGABLE));
        } catch (PackageManager.NameNotFoundException e) {
            //Logger.e(getApplicationContext(), e);
        }}}

 

 

[참고]

https://developer.android.com/studio/build/multidex.html

Leave a Reply

error: Content is protected !!