Could not find .MyApp class on path: DexPathList. Only when running debug apk directly

I was looking for a solution for a solution, and some of them are related to ClassNotFoundException streams like SO. But I tried the solutions offered there and nothing helped. So in my case, when you deploy the application to your device directly from Android Studio it works fine, although it falls during the installation of the file: adb install app-debug.apk.

03-08 16:45:59.303 32233-32233/us.kostenko.glagol.debug E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: us.kostenko.glagol.debug, PID: 32233
                                                                          java.lang.RuntimeException: Unable to instantiate application us.kostenko.glagol.di.application.MyApp: java.lang.ClassNotFoundException: Didn't find class "us.kostenko.glagol.di.application.MyApp" on path: DexPathList[[zip file "/data/app/us.kostenko.glagol.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/us.kostenko.glagol.debug-1/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                              at android.app.LoadedApk.makeApplication(LoadedApk.java:565)
                                                                              at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561)
                                                                              at android.app.ActivityThread.access$1500(ActivityThread.java:154)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:135)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5298)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:372)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:708)
                                                                           Caused by: java.lang.ClassNotFoundException: Didn't find class "us.kostenko.glagol.di.application.MyApp" on path: DexPathList[[zip file "/data/app/us.kostenko.glagol.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/us.kostenko.glagol.debug-1/lib/arm64, /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.Instrumentation.newApplication(Instrumentation.java:980)
                                                                              at android.app.LoadedApk.makeApplication(LoadedApk.java:560)
                                                                              at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561) 
                                                                              at android.app.ActivityThread.access$1500(ActivityThread.java:154) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5298) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:708) 
                                                                            Suppressed: java.lang.ClassNotFoundException: us.kostenko.glagol.di.application.MyApp
                                                                              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)
                                                                                    ... 13 more
                                                                           Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

AndroidManifest.xml

  <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="us.kostenko.glagol">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- For download manager -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
    android:name=".di.application.MyApp"
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label=""
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait"
        android:launchMode="singleTop">
    </activity>
    <activity
        android:name=".personal.SignInActivity"
        android:label="@string/title_activity_sign_in"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait"/>
    <activity
        android:name=".payment.PaymentActivity"
        android:label="@string/title_activity_payment"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity" />
    </activity>
    <service
        android:name=".catalog.service.BookFilesService"
        android:exported="false"
        android:description="@string/about_detail_book_service"/>
    <service
        android:name=".player.PlayerService"
        android:exported="false"
        android:description="@string/about_play_book_service"/>
</application>

and build.gradle:

    apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def superpowered_sdk_path = properties.getProperty('superpowered.dir')

android {
    signingConfigs {
        config {
           ...
        }
    }
    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion
    defaultConfig {
        applicationId "us.kostenko.glagol"
        minSdkVersion rootProject.minSdkVersion
        targetSdkVersion rootProject.targetSdkVersion
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
            // these platforms cover 99% percent of all Android devices
        }

        externalNativeBuild {
            cmake {
                arguments '-DANDROID_PLATFORM=android-16', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_STL=gnustl_static', "-DPATH_TO_SUPERPOWERED:STRING=${superpowered_sdk_path}"
                cFlags '-O3', '-fsigned-char' // full optimization, char data type is signed
                cppFlags '-fsigned-char', "-I${superpowered_sdk_path}"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            applicationIdSuffix ".debug"
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        main {
            jniLibs.srcDirs = ['src/main/jni']
        }
    }
    externalNativeBuild {
        cmake {
            path 'src/main/jni/CMakeLists.txt'
        }
    }
}

kapt {
    generateStubs = true
}

repositories {
//    maven { url 'https://github.com/linchaolong/stetho-realm/raw/master/maven-repo' }
    mavenCentral()
}

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 "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'


    testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    /* Rx - reactive extensions
                https://github.com/ReactiveX/RxAndroid */
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'
    /* Retrofit - networking
                * http://square.imtqy.com/retrofit/ */
    compile "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofit2Version"
    compile "com.squareup.retrofit2:converter-gson:$rootProject.ext.retrofit2Version"
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    /* Gson - json parsing
                * https://github.com/google/gson */
    compile 'com.google.code.gson:gson:2.7'
    /* OkHttp3 - http client
                * http://square.imtqy.com/okhttp/ */
    compile "com.squareup.okhttp3:okhttp:$rootProject.ext.okhttpVersion"
    compile "com.squareup.okhttp3:logging-interceptor:$rootProject.ext.okhttpVersion"
    /* Dagger 2 - DI
                https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2*/
    compile 'com.google.dagger:dagger:2.8'
    kapt "com.google.dagger:dagger-compiler:2.4"
    provided 'org.glassfish:javax.annotation:10.0-b28'

    /* Glide - image loading lib
                 https://github.com/bumptech/glide */
    compile 'com.github.bumptech.glide:glide:3.7.0'integration:1.4.0@aar'
    compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
    /* Realm */
    compile 'io.realm:android-adapters:1.3.0'

    compile 'de.cketti.mailto:email-intent-builder:1.0.0'
    compile 'com.roughike:bottom-bar:2.1.1'
}
repositories {
    mavenCentral()
}

I have this MyApp class in a project. This magazine does nothing for me. I noticed a problem after updating Android Studio to version 2.3 and updating some dependencies in the project. Before it worked fine.

I would be grateful for any help in solving this problem.

Edit: , . Build/Build APK adb install app-debug.apk, . , Run/Run 'app' , apk, , . ?

, Build/Clean .

+4
1

. Instant run , AS apk, . , apk, adb install app-debug.apk, apk Build/Build APK.

+1

Source: https://habr.com/ru/post/1671793/


All Articles