Android Studio E / dalvikvm: Could not find class '.DatabaseHelper' referenced by .DatabaseManager method

Hello, I get this error using Android Studio at runtime, but only on devices with SDK version <= 19. Everything compiles fine, but I get this error in my database class.

java.lang.NoClassDefFoundError: 

Here is my build.gradle application:

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '23.0.1' useLibrary 'org.apache.http.legacy' defaultConfig { minSdkVersion 11 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { release { minifyEnabled true } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.google.android.gms:play-services:7.8.0' compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.github.johnpersano:supertoasts:1.3.4@aar' compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' compile 'com.navercorp.pulltorefresh:library:3.2.0@aar' compile 'com.parse.bolts:bolts-android:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.48' compile 'com.j256.ormlite:ormlite-core:4.48' } 

My Helper database extends OrmLiteSqliteOpenHelper Everything worked fine, while my compileSdkVersion was at 19 Here's what I updated:

  • gradle: classpath 'com.android.tools.build:gradle:1.1.0' > 1.3.0
  • sdk Version: compileSdkVersion 19 > 23
  • appcompat: com.android.support:appcompat-v7:19.0.1 > 23
  • game services

My DatabaseHelper class is in the same package as other classes that work great!

thanks for the help

+8
android android-studio ormlite
source share
3 answers

How are you multiDexEnabled true in your build.gradle. Make sure your application class extends MultiDexApplication instead of the Application class.

Alternatively, as suggested in the docs, you can add the following class to your application class.

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

I found a problem. MultiDex is not supported properly until lollypop. As soon as I remove the additional libraries and remove the multidex configuration on gradle, everything started to work fine.

delete.

  multiDexEnabled true 

Hi

+1
source share

I had the same problem for a while a, try disabling ProGuard

 minifyEnabled false 
0
source share

All Articles