im a begginer in android studio and im trying to perform a database sync with mysql and a android database. after following a guide (it makes no mention to gradle stuff however so im having to improvise) im left with the bellow error
After searching i was told its probably my dependencies but i haven't had much look so far
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/android-async-http-1.4.4.jar')
}
my library in the .idea folder look like this
libraries
android_async_http_1_4_4.xml
android_support_v4.xml
appcompat_v7_21_0_3.xml
gson_2_2_2.xml
support_annotations_21_0_3.xml
support_v4_21_0_3.xml
this is the error i got
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Developer Tools/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Volumes/Untitled/You copy/app/build/intermediates/dex/debug --input-list=/Volumes/Untitled/You copy/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
thank you for any help you can offer me
Gradle knows how to resolve dependency conflicts. You can read about that here : https://gradle.org/docs/current/userguide/dependency_management.html .
So the error is not because appcompat clashes with support-v4.
It looks like you're referencing twice, libraries from your libs folder.
Either use:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/android-async-http-1.4.4.jar') }
or:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
However, my recommendation is to also reference support-v4, gson and android-async as you reference appcompat-v7.
Problem:
With Gradle dependencies, AppCompatv7 also brings in Supportv4. So, simply remove Supportv4 .jar because you are accidentally adding it twice.
Your dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar') // <-- remove jar
compile files('libs/android-async-http-1.4.4.jar')
}
Should be:
I also upgraded your .jars into Gradle dependencies.
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0' // <-- upgraded
compile 'com.google.code.gson:gson:2.3.1' // <-- upgraded to gradle dependency
compile 'com.loopj.android:android-async-http:1.4.4' // <-- upgraded to gradle dependency
}
Related
In app/build.gradle file I feel I constantly have to version bump Firebase-core. I have included Firebase as the setup suggests.
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
compile project(':react-native-fetch-blob')
compile project(':react-native-locale')
compile project(':react-native-fs')
compile project(':react-native-view-shot')
compile project(':react-native-share')
compile project(':react-native-vector-icons')
compile project(':react-native-spinkit')
compile project(':react-native-image-picker')
compile project(':react-native-device-info')
compile project(':react-native-camera')
compile project(':react-native-sqlite-storage')
compile fileTree(dir: "libs", include: ["*.jar"])
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') { transitive = true; }
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.facebook.react:react-native:+'
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
When the version is not up to date the compilation will fail with the error.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzfgf;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzfgf;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForProdDebug FAILED
Is there a better way to include fireabse?
There is an easier way I have come to realize...
In the root build.gradle I now define a variable
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
googlePlayServicesVersion = "16.+"
}
Then in the application's `build.gradle
dependencies {
implementation "com.google.firebase:firebase-core:${rootProject.ext.googlePlayServicesVersion}"
}
It is a little hacky because you are getting the latest version for minor versions/
I got a Gradle Error:
Error converting bytecode to dex: Cause: com.android.dex.DexException:
Multiple dex files define Lcom/coremedia/iso/AbstractBoxParser$1;I
want to used both isoparser-1.0.6.jar and compile
'com.googlecode.mp4parser:isoparser:1.+'
for my development purpose.My Gradle given below
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.googlecode.mp4parser:isoparser:1.+'
compile 'org.apache.commons:commons-io:1.3.2'
compile files('libs/aspectjrt-1.7.3 (1).jar')
compile files('libs/isoparser-1.0.6.jar')
}
Multiple dex files define Lcom/coremedia/iso/
You don't need the JAR files. The fact that you are using them is causing duplicate files, which Gradle can resolve on its own, but only when using Maven dependencies.
You compiled this ISO parser library already . And it depends on aspectjrt, so you don't need to explicitly compile that unless you really want to
https://mvnrepository.com/artifact/com.googlecode.mp4parser/isoparser/1.0.6
compile 'com.googlecode.mp4parser:isoparser:1.0.6'
compile 'org.aspectj:aspectjrt:1.8.2' // This version is used by isoparser:1.0.6
// compile files('libs/aspectjrt-1.7.3 (1).jar')
// compile files('libs/isoparser-1.0.6.jar')
You need to actually delete the JAR files because this line will compile them anyway. In other words, putting compile files() was redundant
compile fileTree(dir: 'libs', include: ['*.jar'])
I am trying to build my app but when i try to make it a signed apk it says this:
Error:Execution failed for task ':app:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\rik\AppData\Local\Android\sdk\build-tools\21.1.0\dx.bat --dex --output C:\Users\rik\Desktop\CCApp\app\build\intermediates\dex\release --input-list=C:\Users\rik\Desktop\CCApp\app\build\intermediates\tmp\dex\release\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
its really anoying me and i need to build the app very soon,
hope someone can help me
EDIT added build.gradle
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "it.experium.ccapp"
minSdkVersion 9
targetSdkVersion 21
versionCode 3
versionName "3.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
}
EDIT file tree of the libs folder
parse-1.8.2-javadoc (Folder)
ParseCrashReporting-1.8.2-javadoc (Folder)
bolts-android-1.1.4 (Jar)
bolts-android-1.1.4 (Properties File)
bolts-android-1.1.4-javadoc (Jar)
Parse-1.8.2 (Jar)
Parse-1.8.2 (Properties file)
Rooster (In english Schedule, i have this because i request json's with this file. Jar)
third_party_licenses (TXT)
It seems like you are using here multiple jar files for same reference it may take some difference version of it..
So, it's better to remove below lines
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
Because 1st and 3rd line of this code included in single line so, no need to put those extra lines..
compile fileTree(dir: 'libs', include: ['*.jar'])
You are here putting external jar bolts-android-1.1.4 (Jar) as a reference from lib folder so, no need to add this gradle dependency..
compile 'com.parse.bolts:bolts-android:1.+'
So, after removing those 3 line sync project you will get your project running without any issue..
Let us know if anything needed...
I have googled to find a solution, but I have tried all the ways and any of them works. First my project works with any problem, later I added some changes and this happened. When I delete all the changes, the problem has not dissapeared. When I try to complie the project, gradle console shows:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/user/Android/Sdk/build-tools/22.0.0/dx --dex --no-optimize --output /home/projectpath/app/build/intermediates/dex/debug --input-list=/home/projectpath/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "application.com.name"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:22.0.+'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.jakewharton.timber:timber:2.5.0'
compile 'fr.tvbarthel.lib.blurdialogfragment:lib:1.1.0#aar'
compile 'com.github.chenupt.android:multiplemodel:1.1.0#aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.google.guava:guava:18.0'
compile 'com.jpardogo.materialtabstrip:library:1.0.8'
compile 'com.getbase:floatingactionbutton:1.7.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
}
This kind of issue UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException:
happens when you are using the same library with a different version.
The problem is here:
You are using
compile 'com.parse.bolts:bolts-android:1.+'
Currently the version is 1.2
The facebook (3.21.1) library is using the 1.1.2 version
Also you are using
compile 'com.android.support:appcompat-v7:+'
It means the release 22.
The facebook library uses the 20-21.
i am newbie to Android Studio, every time when try to Run my app, face the exception
Error:Execution failed for task ':abc:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/nik/Installs/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/nik/workspace/androidstudio/abc/build/intermediates/dex/debug --input-list=/home/nik/workspace/androidstudio/abc/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/abc/xyz/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
try lot of solution like delete BuildConfig file etc but without luck. After lot of googling i just understand, problem related to multiple dependencies file but unable to solve.
Also try command
gradle -q dependencies
but fail with this error
FAILURE: Build aborted because of an internal error.
What went wrong:
Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
Also i like to mention i am try to migrate my project from eclipse and its build successfully when run Build->Rebuild Project in Android Studio
boxAndroidLibraryV2
dependencies {
compile project(':boxJavaLibraryV2')
compile 'com.android.support:support-v4:19.1.0'
//compile 'com.android.support:support-v4:18.0.0'
compile files('libs/commons-codec.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
}
boxJavaLibraryV2
dependencies {
compile files('libs/cglib-nodep-2.2.2.jar')
compile files('libs/commons-codec-1.6.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/easymock-3.1.jar')
compile files('libs/httpclient-4.2.5.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpcore-4.2.4.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
compile files('libs/junit-4.8.2.jar')
compile files('libs/powermock-easymock-1.4.12-full.jar')
compile files('libs/robolectric-1.2-20121030.213744-165-jar-with-dependencies.jar')
}
mylib
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.guava:guava:17.0'
compile files('libs/commons-codec.jar')
compile files('libs/sqlcipher.jar')
}
myApp
dependencies {
compile project(':boxAndroidLibraryV2')
compile project(':liveSdk')
compile project(':mylib')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/HockeySDK-3.0.2.jar')
compile files('libs/dropbox-android-sdk-1.5.4.jar')
compile files('libs/google-api-client-1.14.1-beta.jar')
compile files('libs/google-api-client-android-1.14.1-beta.jar')
compile files('libs/google-api-services-drive-v2-rev70-1.14.1-beta.jar')
compile files('libs/google-http-client-1.14.1-beta.jar')
compile files('libs/google-http-client-android-1.14.1-beta.jar')
compile files('libs/google-oauth-client-1.14.1-beta.jar')
compile files('libs/icu4j-4.8.1.jar')
compile files('libs/in-app-purchasing-2.0.59.jar')
compile files('libs/json_simple-1.1.jar')
}
i know some dependencies are multiple in box library like
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
but if i am try to remove these than face exception
Error:(6, 29) error: package org.apache.commons.io does not exist
Error:(80, 13) error: cannot find symbol variable IOUtils
Error:(6, 32) error: cannot find symbol class CharEncoding
Error:(57, 75) error: cannot find symbol variable CharEncoding
Error:(58, 79) error: cannot find symbol variable CharEncoding etc...
Thanks for any suggestion
after lot of trials
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
this worked for me..