1

When I run my application in android 4.4 - 4.4.x devices my app crashes, but when I run with android 5.0 onwards its working fine.

Crash logcat:

FATAL EXCEPTION: main                                                                      
Process: com.Forewarn.ForewarnApp, PID: 18854
  java.lang.VerifyError: com/Forewarn/ForewarnApp/activities/SignInActivity
      at java.lang.Class.newInstanceImpl(Native Method)
      at java.lang.Class.newInstance(Class.java:1208)
      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
      at android.app.ActivityThread.access$800(ActivityThread.java:145)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5127)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
      at dalvik.system.NativeStart.main(Native Method)

Here is my Application class :

public class SoteriaApplication extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        AccountUtils.assignContext(this);
    }

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

I tried with disable instant run from settings and tried with added above attachBaseContext() Method in Application class :

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

I used these libraries in my Gradle:

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 files('libs/gson-2.3.1.jar')
    compile files('libs/retrofit-1.2.2.jar')
    compile files('libs/picasso-2.5.2.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')

    compile 'com.vdurmont:semver4j:2.2.0'

    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:cardview-v7:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.android.support:palette-v7:27.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'org.jsoup:jsoup:1.8.3'
    testCompile 'junit:junit:4.12'

}

please find the problem in my code, and already some users also bothered about this issue but No one find out the solution, that's why I again posted my issue.

Thanks Everyone!

Paul Chu
  • 1,249
  • 3
  • 19
  • 27
Dolly Rosy
  • 140
  • 10

4 Answers4

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

Remove above code from application class and then try to check whether is working or not

because its working in my project without this bunch of code

so let me know

hope this will work for you

0

This is probably because of the incorrect Multidex configuration. You can try using only Multidex.install() in your application. Don't extend the MultiDexApplication. Something like this:

public class SoteriaApplication extends Application {

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

  ...

}

and use implementation 'com.android.support:multidex:1.0.2'

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
0
 defaultConfig {
        applicationId "com.sample.app"  // your package name
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true  // adding multidex support
        vectorDrawables.useSupportLibrary = true  // adding vector drawable support
    }

In Dependencies :

 compile 'com.android.support:multidex:1.0.2'

App Class :

   public class AppClass extends MultiDexApplication {
        public static Context context;

        @Override
        public void onCreate() {
            super.onCreate();
            // Your code here
        }
}

Please refer to this link as well

Deep Patel
  • 2,584
  • 2
  • 15
  • 28
-1

Fixed My Problem because of some higher level version supported icons i used for lower lever screen's, that's y it's crashed on 4.4 versions phones :

Example : home.png(v21) it is a drawable i used in my app but its applicable and allow to used from android api level 21 onwards only .. that's why crashed on 4.4(api level 19) devices

Dolly Rosy
  • 140
  • 10