jdbc接口

时间:2017-03-05 10:02:52

标签: java android mysql jdbc

我的应用程序在libs文件夹中有mysql-connector-java-5.1.34.jar,它运行正常。在昨天更新到android studio 2.3后,我开始收到错误

Suppressed: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err:     at java.lang.Class.classForName(Native Method)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

我尝试用最新下载的6.0.5更改MySQL连接器并尝试编译,它给出了另一个错误

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

如何修复它。虽然我试图在上面找到一些信息

Android: Dex cannot parse version 52 byte code

但没有任何对我有用,下面是我更新的gradle。

  compileSdkVersion 25
    buildToolsVersion '25.0.0'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "jss.smartapp"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 12
        versionName "1.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    sourceCompatibility = 1.7
    targetCompatibility = 1.7

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.SigningInfo
        }
        debug {
            signingConfig signingConfigs.SigningInfo
        }
    }
    productFlavors {
        def BOOLEAN = "boolean"
        def TRUE = "true"
        def FALSE = "false"
        def A_FIELD = "A_FIELD"

        internal {
            buildConfigField BOOLEAN, A_FIELD, FALSE
        }

        official {
            buildConfigField BOOLEAN, A_FIELD, TRUE
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
    }
}

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 'com.android.support:appcompat-v7:25.2.0'
    testCompile 'junit:junit:4.12'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    //For Instamojo.
    compile 'com.instamojo:android-sdk:+'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    //Apache IO
    compile files('libs/commons-io-2.5.jar')
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'

0 个答案:

没有答案