[英]Connecting MySql with Android Studio
Well I have some errors when I put the MySQL connector and I don`t know why. 好吧,当我放入MySQL连接器时,我有些错误,但我不知道为什么。
I have researched in here(stackoverflow) and I've tried to change the build.gradle app or the modules and it doesn't working. 我在这里进行了研究(stackoverflow),我试图更改build.gradle应用程序或模块,但它不起作用。 If anyone knows what's the problem it would help me a lot.. Thank You.. 如果有人知道这是什么问题,它将对我有很大帮助。。谢谢。
Errors: 错误:
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 Android Studio中的错误
I add my code to: 我将代码添加到:
build.gradle app: build.gradle应用程序:
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'
Project module: 项目模块:
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 module: MySQL模块:
configurations.maybeCreate("default")
artifacts.add("default", file('mysql-connector-java-5.1.37-bin.jar'))
My be a bit late, but I have just found the solution for this problem: 我来晚了一点,但我刚刚找到了解决此问题的方法:
You could write in the app/build.gradle this code: 您可以在app / build.gradle中编写以下代码:
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 https://developer.android.com/guide/platform/j8-jack.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.