Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ormlite NoClassDefFoundError on Samsung S4 API 21

The android project runs without problem on Samsung S7 API 24, Nexus 6 API 24, API 23 Emulator, Pixel API 23 and Galaxy Note 23 API emulators.

When I run it on devices or emulators with API 22 or 21, the following exception is thrown the first time App is launched.

05-04 11:48:25.045 10463-10463/com.xyz.abc E/AndroidRuntime: FATAL EXCEPTION: main
          Process: com.xyz.abc, PID: 10463
                                                              java.lang.NoClassDefFoundError: com.xyz.abc.database.helper.AbcDatabaseHelper
                       at com.xyz.abc.database.daos.UserRecordDao.<init>(UserRecordDao.java:32)
                       at com.xyz.abc.AbcApplication.onCreate(AbcApplication.java:148)
                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5113)
                       at android.app.ActivityThread.access$1600(ActivityThread.java:177)
                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loop(Looper.java:145)
                       at android.app.ActivityThread.main(ActivityThread.java:5942)
                       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:1400)
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

Why and how can I fix it?

Below is the build.gradle

apply plugin: 'com.android.application'

repositories {
maven { url "https://jitpack.io" }
}

android {
compileSdkVersion 25

buildToolsVersion '25.0.3'

defaultConfig {
    applicationId "com.xyz.abc"
    minSdkVersion 21
    targetSdkVersion 22
    versionCode Integer.parseInt(project.VERSION_CODE)
    versionName project.VERSION_NAME
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    multiDexEnabled false
}

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

dexOptions {
    preDexLibraries = false
    javaMaxHeapSize "2g"
}

aaptOptions {
    cruncherEnabled = false
}

packagingOptions {

    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/DEPENDENCIES.txt'
}
}

dependencies {

// Required -- JUnit 4 framework
// Optional -- Mockito framework
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/aws/aws-android-sdk-cognito-2.1.10.jar')
compile files('libs/aws/aws-android-sdk-core-2.1.10.jar')
compile files('libs/aws/aws-android-sdk-s3-2.1.10.jar')
compile('com.google.maps.android:android-maps-utils:0.4+') {
    exclude group: "com.google.android.gms"
}
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.marshalchen.ultimaterecyclerview:library:0.7.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
compile 'com.ogaclejapan.smarttablayout:library:1.6.0@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.0@aar'
compile 'com.github.ppamorim:dragger:1.2'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.1'
compile 'com.mixpanel.android:mixpanel-android:4.+'
compile 'com.wdullaer:materialdatetimepicker:3.1.3'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.github.frank-zhu:pullzoomview:1.0.0'
compile 'com.github.techery:properratingbar:0.0.5'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
}


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

Log out put from running it on API 22

05-08 21:18:33.431 4597-4597/? E/libprocessgroup: failed to make and chown /acct/uid_10059: Read-only file system
05-08 21:18:33.431 4597-4597/? W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
05-08 21:18:33.432 4597-4597/? I/art: Not late-enabling -Xcheck:jni (already on)
05-08 21:18:33.471 4597-4597/com.xyz.abc W/ResourcesManager: Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
05-08 21:18:34.038 4597-4625/com.xyz.abc W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-08 21:18:34.051 4597-4625/com.xyz.abc W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-08 21:18:34.062 4597-4597/com.xyz.abc W/InstanceID/Rpc: Found 10007
05-08 21:18:34.063 4597-4625/com.xyz.abc W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
05-08 21:18:34.065 4597-4625/com.xyz.abc W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
05-08 21:18:34.096 4597-4597/com.xyz.abc I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
05-08 21:18:34.096 4597-4597/com.xyz.abc I/DynamiteModule: Selected local version of com.google.android.gms.flags
05-08 21:18:34.109 4597-4597/com.xyz.abc W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
05-08 21:18:34.113 4597-4597/com.xyz.abc I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:4
05-08 21:18:34.113 4597-4597/com.xyz.abc I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 4
05-08 21:18:34.125 4597-4597/com.xyz.abc I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader p[DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000003/DynamiteModulesC_GmsCore_prodlmp_alldpi_release.apk"],

nativeLibraryDirectories=[/vendor/lib, /system/lib]]]
05-08 21:18:34.138 4597-4597/com.xyz.abc I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
05-08 21:18:34.138 4597-4597/com.xyz.abc I/DynamiteModule: Selected local version of com.google.android.gms.flags
05-08 21:18:34.144 4597-4597/com.xyz.abc W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
05-08 21:18:34.182 4597-4597/com.xyz.abc I/FA: App measurement is starting up, version: 10084
05-08 21:18:34.182 4597-4597/com.xyz.abc I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
05-08 21:18:34.182 4597-4597/com.xyz.abc D/FA: Debug-level message logging enabled
05-08 21:18:34.182 4597-4597/com.xyz.abc D/FA: AppMeasurement singleton hash: 1038524578
05-08 21:18:34.196 4597-4597/com.xyz.abc I/FA: To enable faster debug mode event logging run:
                                                  adb shell setprop debug.firebase.analytics.app com.xyz.abc
05-08 21:18:34.235 4597-4597/com.xyz.abc I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.zzbks@3824b269
05-08 21:18:34.235 4597-4597/com.xyz.abc I/FirebaseInitProvider: FirebaseApp initialization successful
05-08 21:18:34.236 4597-4597/com.xyz.abc I/InstantRun: starting instant run server: is main process
05-08 21:18:34.240 4597-4597/com.xyz.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<com.xyz.abc.database.helper.AbcDatabaseHelper>
05-08 21:18:34.240 4597-4597/com.xyz.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<com.xyz.abc.database.helper.AbcDatabaseHelper>
05-08 21:18:34.240 4597-4597/com.xyz.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<com.xyz.abc.database.helper.AbcDatabaseHelper>
05-08 21:18:34.240 4597-4597/com.xyz.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<com.xyz.abc.database.helper.AbcDatabaseHelper>
05-08 21:18:34.249 4597-4597/com.xyz.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<com.xyz.abc.database.helper.AbcDatabaseHelper>
05-08 21:18:34.249 4597-4597/com.xyz.abc D/AndroidRuntime: Shutting down VM
05-08 21:18:34.250 4597-4597/com.xyz.abc E/UncaughtException: java.lang.NoClassDefFoundError: com.xyz.abc.database.helper.AbcDatabaseHelper
                                                                   at com.xyz.abc.database.daos.UserRecordDao.<init>(UserRecordDao.java:32)
                                                                   at com.xyz.abc.AbcApplication.onCreate(AbcApplication.java:140)
                                                                   at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
                                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
                                                                   at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:135)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                   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:903)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-08 21:18:34.261 4597-4638/com.xyz.abc I/DynamiteModule: Considering local module com.google.android.gms.tagmanager:8 and remote module com.google.android.gms.tagmanager:9
05-08 21:18:34.261 4597-4638/com.xyz.abc I/DynamiteModule: Selected remote version of com.google.android.gms.tagmanager, version >= 9
05-08 21:18:34.285 4597-4638/com.xyz.abc W/GoogleTagManager: No container asset found in /assets/containers. Checking top level /assets directory for container assets.
05-08 21:18:34.304 4597-4638/com.xyz.abc W/GoogleTagManager: Tag Manager's event handler WILL NOT be installed (no container loaded)
05-08 21:18:34.305 4597-4638/com.xyz.abc I/GoogleTagManager: Tag Manager initilization took 37ms
05-08 21:18:34.309 4597-4638/com.xyz.abc D/FA: Logging event (FE): _ae, Bundle[{_o=crash, timestamp=1494292714250, fatal=1}]
05-08 21:18:34.471 4597-4597/com.xyz.abc E/AndroidRuntime: FATAL EXCEPTION: main
                                                            Process: com.xyz.abc, PID: 4597
                                                            java.lang.NoClassDefFoundError: com.xyz.abc.database.helper.AbcDatabaseHelper
                                                                at com.xyz.abc.database.daos.UserRecordDao.<init>(UserRecordDao.java:32)
                                                                at com.xyz.abc.AbcApplication.onCreate(AbcApplication.java:140)
                                                                at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
                                                                at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
                                                                at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                at android.os.Looper.loop(Looper.java:135)
                                                                at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                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:903)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-08 21:22:57.870 4597-4597/? I/Process: Sending signal. PID: 4597 SIG: 9
like image 869
windchime Avatar asked May 04 '17 16:05

windchime


1 Answers

First, try to clean the project. Faced the similar issues at past, and cleaning and rebuilding the project solved my cases.


Secnd, If your AbcDatabaseHelper class is not public, it will be accessible to only same package/folder.

change

class AbcDatabaseHelper {

}

to

public class AbcDatabaseHelper {

}

And also, some libraries and methods can be missing on Samsung devices like S4 Mini, S3 Mini, S4, Note 2 etc. Some 3rd party libraries may not work in some cases.

like image 86
Oğuzhan Döngül Avatar answered Nov 07 '22 15:11

Oğuzhan Döngül