0

Here's a list of things I have tried:

  1. Disabled Instant Run (It was disabled before, since I don't use it anyways)
  2. Cleaned and rebuilt my project
  3. Checked name of project is the same everywhere
  4. multiDexEnabled is set to true
  5. Followed all steps shown in this link
  6. Invalidate cache & restart
  7. Created a new project and copied code from previous project

Before adding the MultiDexApplication line in Manifest I got the following stacktrace:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.prajjwal.myfreight_0, PID: 27367
              java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.prajjwal.myfreight_0/com.prajjwal.myfreight_0.Splash}: java.lang.ClassNotFoundException: Didn't find class "com.prajjwal.myfreight_0.Splash" on path: DexPathList[[zip file "/data/app/com.prajjwal.myfreight_0-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2486)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656)
                  at android.app.ActivityThread.access$800(ActivityThread.java:178)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:194)
                  at android.app.ActivityThread.main(ActivityThread.java:5692)
                  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:959)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "com.prajjwal.myfreight_0.Splash" on path: DexPathList[[zip file "/data/app/com.prajjwal.myfreight_0-1/base.apk"],nativeLibraryDirectories=[/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.newActivity(Instrumentation.java:1074)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2463)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656) 
                  at android.app.ActivityThread.access$800(ActivityThread.java:178) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512) 
                  at android.os.Handler.dispatchMessage(Handler.java:111) 
                  at android.os.Looper.loop(Looper.java:194) 
                  at android.app.ActivityThread.main(ActivityThread.java:5692) 
                  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:959) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
                Suppressed: java.lang.ClassNotFoundException: com.prajjwal.myfreight_0.Splash
                  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

After adding that line I'm getting this:

12-30 16:44:12.980 5272-5272/prajjwal.com.myfreight E/AndroidRuntime: FATAL EXCEPTION: main
                                                                  Process: prajjwal.com.myfreight, PID: 5272
                                                                  java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/prajjwal.com.myfreight-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
                                                                      at android.app.LoadedApk.makeApplication(LoadedApk.java:572)
                                                                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4883)
                                                                      at android.app.ActivityThread.access$1500(ActivityThread.java:178)
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                      at android.os.Looper.loop(Looper.java:194)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5692)
                                                                      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:959)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
                                                                   Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/prajjwal.com.myfreight-1/base.apk"],nativeLibraryDirectories=[/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:988)
                                                                      at android.app.LoadedApk.makeApplication(LoadedApk.java:567)
                                                                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4883) 
                                                                      at android.app.ActivityThread.access$1500(ActivityThread.java:178) 
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:111) 
                                                                      at android.os.Looper.loop(Looper.java:194) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5692) 
                                                                      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:959) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
                                                                    Suppressed: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
                                                                      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

I'm at my wits end and would appreciate any help.

EDIT: First stacktrace is from the old project and second one is from the new one I created

build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
    applicationId "prajjwal.com.myfreight"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

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

dexOptions {

    javaMaxHeapSize "5120"
}

afterEvaluate {
    tasks.matching {
        it.name.startsWith('dex')
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = ['--multi-dex']
        } else {
            dx.additionalParameters += '--multi-dex'
        }
    }
}

subprojects {
    project.plugins.whenPluginAdded { plugin ->
        if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = false
        } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = false
        }
    }
}
 }

 dependencies {

/*implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'*/
compile files('libs/jtds-1.2.8-a46da18a7c06f34fb19c38538665cbe1.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:gridlayout-v7:25.4.0'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
/*testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'*/
}

1 Answers1

0

Use this

compileSdkVersion "26.0.0"
buildToolsVersion "26.0.0"

instead of this

compileSdkVersion 25
buildToolsVersion "26.0.0"
AskNilesh
  • 67,701
  • 16
  • 123
  • 163