1

my app has mysql-connector-java-5.1.34.jar in libs folder and it was working fine. Now after yesterday's update to android studio 2.3, I start getting error

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)

I tried to change MySQL connector with 6.0.5 the latest downloaded and try to compile, it is giving another error

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.

How to fix it. though I tried to find some information on above here

Android: Dex cannot parse version 52 byte code

but nothing worked for me, below is my updated 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'
Community
  • 1
  • 1
Panache
  • 1,701
  • 3
  • 19
  • 33
  • 1
    1) Don't access databases directly from android, 2) this means you are trying to use a library compiled with Java 8, which can't be used from Android. Also given the gradle file included, you don't seem to have followed the instructions in the accepted answer to the question you link. – Mark Rotteveel Mar 05 '17 at 10:17
  • So means, I should not add java connector. and this will solve the issue. – Panache Mar 05 '17 at 10:25

0 Answers0