2016-10-25 2 views
0

Nun, ich habe einige Fehler, wenn ich den MySQL-Connector und ich weiß nicht warum.Verbinden von MySql mit Android Studio

Ich habe hier recherchiert (stackoverflow) und ich habe versucht, die build.gradle App oder die Module zu ändern, und es funktioniert nicht. Wenn jemand weiß, was ist das Problem wäre es mir sehr helfen .. Danke ..

Fehler:

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. 


Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process 

Errors in Android Studio

Ich füge meinen Code:

build.gradle App :

apply plugin: 'com.android.application' 


android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.3" 
    defaultConfig { 
     applicationId "com.example.informatica.xabiagame" 
     minSdkVersion 15 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

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:24.2.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.google.android.gms:play-services-maps:9.6.1' 
    compile 'com.google.android.gms:play-services-ads:9.6.1' 
    compile 'com.google.android.gms:play-services:9.6.1' 
    testCompile 'junit:junit:4.12' 
    compile 'com.google.android.gms:play-services-auth:9.6.1' 
    compile project(':MySQL') 
} 

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

Projektmodul:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 
     classpath 'com.google.gms:google-services:3.0.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

MySQL-Modul:

configurations.maybeCreate("default") 
artifacts.add("default", file('mysql-connector-java-5.1.37-bin.jar')) 

Antwort

1

Mein ein bisschen spät, aber ich habe festgestellt, nur die Lösung für dieses Problem:

  1. MySQL Connector 5.1 ist mit Java kompiliert 8.
  2. Noch unterstützt Android Studio 2.3 nicht direkt Java 8.
  3. Sie könnten in der App/build.gradle diesen Code schreiben:

    android { 
        defaultConfig 
        { 
         jackOptions 
         { 
         enabled true 
         } 
        compileOptions 
        { 
         sourceCompatibility JavaVersion.VERSION_1_8 
         targetCompatibility JavaVersion.VERSION_1_8 
        } 
        } 
    

    https://developer.android.com/guide/platform/j8-jack.html