Android Studio中E / dalvikvm:找不到类的.DatabaseHelper“,从法引用.DatabaseManager [英] Android Studio E/dalvikvm﹕ Could not find class '.DatabaseHelper', referenced from method .DatabaseManager

查看:3018
本文介绍了Android Studio中E / dalvikvm:找不到类的.DatabaseHelper“,从法引用.DatabaseManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我得到的运行时间,但只有在与SDK版本&LT设备使用Android工作室这个错误= 19,一切都编译好,但我得到我的databaseHelper类此错误

Hello I'm getting this error using Android Studio on runtime but only on devices with an SDK version <= 19. Everything compiles ok but I get this error on my databaseHelper Class.

java.lang.NoClassDefFoundError:

下面是我的应用程序的build.gradle:

Here is my app build.gradle:

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'
}

我databaseHelper类扩展 OrmLiteSqliteOpenHelper
一切工作正常,而我compileSdkVersion是在19
以下是我更新:

My databaseHelper class extends OrmLiteSqliteOpenHelper Everything was working fine while my compileSdkVersion was at 19 Here is what I updated:


  • gradle这个:类路径com.android.tools.build:gradle:1.1.0> 1.3.0

  • SDK版本: compileSdkVersion 19 > 23

  • 应用程序兼容性: com.android.support:appcompat-v7:19.0.1 > 23

  • 播放服务

  • 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
  • play-services

我databaseHelper类是在同一个包超过其正常工作之外的类!

My databaseHelper Class is in the same package than other Classes which work fine !

感谢您的帮助。

推荐答案

你有在你的build.gradle multiDexEnabled真正。请确保您的应用程序类的扩展 MultiDexApplication 代替应用类。

As you have multiDexEnabled true in your build.gradle. Make sure your application class is extending MultiDexApplication instead of the Application class.

另外,如在文档的建议,可以在下面的方法添加到您的应用程序类。

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

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

这篇关于Android Studio中E / dalvikvm:找不到类的.DatabaseHelper“,从法引用.DatabaseManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆