MPAndroidChart Android Studio Errors while building APK - android

I was trying some tutorials about MPAndroidChart and its worked so well in my emulator. But when I try to build the APK, I've got two errors ...
"Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/github/mikephil/charting/BuildConfig;"
"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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2"
can someone help me ...
this is my build.gradle script
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.myname.lesson03"
minSdkVersion 7
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile ('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.1.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
testCompile 'junit:junit:4.12'
}

Possibly you have the same library/directory included more than once in your build.gradle's dependencies.
My suggestion is to check your 'libs' folder. Make sure you only reference MPAndroidChart once.
Also, try to comment out this line:
compile fileTree(include: ['*.jar'], dir: 'libs')

Related

Android studio through Multi Dex error in my project

I tried to run my app in ANdroid Studio but I have this error :
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/loopj/android/http/AsyncHttpClient$1;
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2
I don't know where is the problem.
I am not able to modify and run anything as it don't run anymore.
Thank's in advance for you're help.
For example my class mainactivity have one error in :
addOnPageChangeListener
My gradle :
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "info.picse.kids_phone"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.3.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:support-v4:23.3.0'
}
my libs :
enter image description here
On that screenshot you also have jar for gson. Here's the gradle for gson:
//gson 2.2.2
compile 'com.google.code.gson:gson:2.2.2'
Dont forget add the maven
repositories {
mavenCentral()
}

Error:The number of method references in a .dex file cannot exceed 64K.6

I want to build apk file, but i cant, because i have 2 errors. I tried lots of solutions, for example multiDexEnabled true or something like that, but didnt work.. Please help:)
Errors:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_92\bin\java.exe'' finished with non-zero exit value 2
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "sgtt.celtkituzes_0_1"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.backendless:backendless:3.0.20.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.firebaseui:firebase-ui-database:0.5.1'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
You shouldn't ever be using compile 'com.google.android.gms:play-services:9.4.0' as that includes every Google Play services library - only use the APIs you need.
This should reduce your method count enough to fit under the 64K limit.

Incompatibility between some android libraries and google play services

I use the following libraries in build.gradle (app), and there some libraries in libs folder such as: "Arcgis SDK and ksoap2 and gcm.jar" in android-studio project, when I builds it, causes the following error:
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
this is the build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.eywa.paltrack"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
}
And when I remove (Arcgis SDK) or (com.android.support:design) or (com.google.android.gms:play-services) when I remove one of them the project builds successfully. and I need all of them. can you help me about this problem?
Regarding the described error in your comments:
"java.lang.OutOfMemoryError: GC overhead limit exceeded Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 3 "
Add this section to the android-section in your build.gradle:
android {
dexOptions {
javaMaxHeapSize "4g"
}
We are facing the problem, after updating to gradle-plugin 1.5.0. This solved our problem.

Gradle build failed with an Exception

I am quite new to the studio,
I am trying to Run my application
Error is encountered -
What went wrong:
Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
I tried with jdk 1.8 which gave the same error.
So found few answers which said to reduce jdk to 1.7
but the Error still persists
Please Suggest what to do
Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "innovapptive.com.mworkorder"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
}
This is what worked for me taken from this answer:
defaultConfig {
multiDexEnabled true
}
What worked for me was: Build-> Rebuild Project
I fllow the first answer and then another problem caused:
**Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/umeng/analytics/AnalyticsConfig.class**
Then it happened:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/umeng/analytics/AnalyticsConfig.class
So I tried to remove this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':libraries:SlidingMenu')
compile files('libs/volley_src.jar')
compile files('libs/Volley_bin.jar')
// compile 'com.umeng.analytics:analytics:latest.integration'
// compile files('libs/umeng-analytics-v5.6.1.jar')
compile files('libs/xUtils-2.6.14.jar')
}
It works and I don't know why,I may try the latest Umeng SDK later.
It may work for you if you are using count and analysis SDK.

Android google play services duplicate entry

I'm trying to use google services in my Android app, but I was getting the following error:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_11\bin\java.exe'' finished with non-zero exit value 2
I was told to try adding multiDexEnabled = true and now the error has changed to this:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/GooglePlayServicesAvailabilityException.class
I looked through my libs but wasn't able to find any conflicts between them.
My jars:
gdata-client-1.0.jar
gdata-client-meta-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-play-services.jar
My project gradle file has the following dependencies:
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
My module gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.mydomain.myproject"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.code.gson:gson:2.3.1'
compile group: 'com.google.guava', name: 'guava', version: '18.0'
}
Any help on fixing these errors would be appreciated.
I looked through my libs but wasn't able to find any conflicts between them
google-play-services.jar would appear to conflict with compile 'com.google.android.gms:play-services:7.5.0'. Remove that JAR and see if that helps.

Categories

Resources