Well I have some errors when I put the MySQL connector and I don`t know why.
I have researched in here(stackoverflow) and I've tried to change the build.gradle app or the modules and it doesn't working. 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
I add my code to:
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'
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:
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:
MySQL connector 5.1 is compiled with Java 8.
Even now Android Studio 2.3 is not directly supporting Java 8.
You could write in the app/build.gradle this code:
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
Related
I am developing an Android application and I am using 'Firebase-Messaging' library in my application. Now I need to 'proguard' and unfortunatly, 'Firebase' generated errors. I searched for solution and then I change the 'buildToolVersion' version 25.0.0 into 26.0.2. When I changed the versions I got the below error. I tried lot of solutions from internet including the 'Firebase Github' itself, but no good. I am using 'Firebase-Messaging 12.0.1' and below is the error I get.
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.2) from [com.android.support:design:26.0.2] AndroidManifest.xml:28:13-35
is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.
build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.sample.firebase"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'me.angrybyte.goose:goose:1.8.0'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.jpardogo.googleprogressbar:library:1.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
You need to change this line of code:
compile 'com.android.support:appcompat-v7:26.0.0'
with
compile 'com.android.support:appcompat-v7:26.0.2'
All dependencies must be the same version.
I am using Android Studio 3 preview to code and build a android kotlin project but it does not seem to compile due to this error:
: java.lang.Exception: Unable to get response from daemon in 10000 ms
Could not perform incremental compilation: Could not connect to Kotlin
compile daemon Could not connect to kotlin daemon. Using fallback
strategy.
Error:Failed to complete Gradle execution.
Cause:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
Here is my gradle build file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.jr.app"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "String", "DEMO_SERVER_URL", "https://demoserver.restlet.net/v1/"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:design:26.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.android.support:support-v4:26.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
Thanks
Maybe you have the same error I had.
I solved here
Try to close android studio, delete .gradle and then open it. I had the same problem and it's fixed now.
I'm trying to send an e-mail like in this post:
Sending Email in Android using JavaMail API without using the default/built-in app
And adding in my build.gradle and app file this lines: https://javaee.github.io/javamail/Android
Error:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'. >
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: com.android.dex.DexException:
Multiple dex files define
Lcom/sun/activation/registries/LineTokenizer;
But with the following app file I have a execution failed and don't know why.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.github.ocaparrostortosa.MyApplication"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
}
dependencies {
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And this one is my Project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can someone help me please? I'm close to finish the project :D
P.D: Sorry for my English and for the presentation, I'm new in stackoverflow.
this error is quite tricky. i also had a hard time on this. I solve my problem somehow by adding this multiDexEnabled true on my gradle build.config
android {
defaultConfig {
minSdkVersion 14 x
targetSdkVersion 23
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Take note, this solution is case to case basis.
One scenario is - my app was very large that it exceeds 64MB limit. If this does not work, check your dependencies.
Other scenario was caused by Google Maps API dependencies that the version needs to be inline with the APP target SDK.
I have just downloaded latest Android Studio 3.0 Preview Canary 2. It has updated my project with latest gradle com.android.tools.build:gradle:3.0.0-alpha2. And now I have a lot of compile crashes like:
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xhdpi-v4\notification_bg_low_normal.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xhdpi-v4\notification_bg_low_normal.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\drawable-xxxhdpi-v4\design_ic_visibility.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\drawable-xxxhdpi-v4\design_ic_visibility.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_menu_hardkey_panel_mtrl_mult.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_menu_hardkey_panel_mtrl_mult.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xxxhdpi-v4\abc_spinner_mtrl_am_alpha.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xxxhdpi-v4\abc_spinner_mtrl_am_alpha.9.png not a valid resource file
ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_btn_check_to_on_mtrl_000.png not a valid resource file
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed: aapt2 compile -o D:\AndroidProjects\GetPet\app\build\intermediates\res\merged\debug C:\Users\user\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\layout\design_navigation_item.xml Issues:
- ERROR: C:\Users\user\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\layout\design_navigation_item.xml not a valid resource file
I have tried to clean project and gradle cache, but useless.
My build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
// 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
}
And app\build.gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'alias'
keyPassword 'pass'
storeFile file('release_keystor.jks')
storePassword 'pass'
}
}
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.org.app"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.vk:androidsdk:1.6.5'
}
Try to change service directory path to something without cyrillic symbols, like "C:/gradle" in
Settings > Build, Execution, Deployment > Gradle
And don't forget to invalidate caches.
After upgrading to Android design tools 24, my project won't run anymore. It builds fine without any errors, but when I run it I get the error:
Error:Gradle: Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_102\bin\java.exe'' finished with non-zero exit value 1
This is my build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.don.mstp"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.Lukle:ClickableAreasImages:v0.1'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.github.javiersantos:MaterialstyledDialogs:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.ramotion.foldingcell:folding-cell:1.0.1'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
compile 'com.github.gabrielemariotti.recyclerview:recyclerview-animators:0.3.0-SNAPSHOT#aar'
compile 'com.tiancaicc.springfloatingactionmenu:library:0.0.2'
compile 'com.daimajia.numberprogressbar:library:1.2#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.daprlabs.aaron:cardstack:0.3.0'
compile 'com.txusballesteros:FitChart:1.0'
compile 'com.github.SilenceDut:ExpandableLayout:v1.0.1'
}
I finally got my project to run and this is how:
Apparently, It is not possible to use Jack compiler with Realm at the moment, because Jack does not support bytecode manipulation (Javassist / Transform API). That being said we can however for now use 'retrolambda' and remove jackOptions.
in your build.gradle
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
in the projects main gradle add class path:
dependencies {
classpath 'io.realm:realm-gradle-plugin:0.88.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
And that got my project running again.