I updated to the last version of Android studio 2.0 Beta 6 with the gradle :
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
}
The app works perfectly fine on emulator and devices I tested every thing and it works fine.
I got many errors only when I try to Generate Signed APK,
I got some errors in dependencies, all of them solved when i excluded vector drawable, vector animate drawable and Support-v4 library
Now i dont have any dependencies error.
now my gradle.build for the app module looks like this:
apply plugin: 'com.android.application'
android {
configurations {
//all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude module: 'animated-vector-drawable'
all*.exclude module: 'support-vector-drawable'
//all*.exclude module: 'support-v4'
}
repositories {
maven { url "https://jitpack.io" }
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.test.test"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1"
// multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.github.afollestad.material-dialogs:commons:0.8.5.5@aar') {
transitive = true
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile('com.google.android.gms:play-services-ads:8.4.0') {
exclude module: 'support-v4'
}
compile('com.google.android.gms:play-services-analytics:8.4.0') {
exclude module: 'support-v4'
}
compile('com.android.support:appcompat-v7:23.2.0') {
exclude module: 'support-v4'
exclude module: 'animated-vector-drawable'
exclude module: 'support-vector-drawable'
}
compile('com.android.support:support-v4:23.2.0') {
exclude module: 'animated-vector-drawable'
exclude module: 'support-vector-drawable'
}
compile('com.android.support:palette-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:cardview-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:design:23.2.0') {
exclude module: 'support-v4'
}
compile('com.nineoldandroids:library:2.4.0') {
exclude module: 'support-v4'
}
compile('com.baoyz.swipemenulistview:library:1.2.1') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile('com.squareup.picasso:picasso:2.5.2') {
exclude module: 'support-v4'
}
compile('com.nononsenseapps:filepicker:2.5.0') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile 'com.google.code.gson:gson:2.6.1'
}
The errors shows up only when I build for release:
This is the error when i turn on multiDex:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
And this is the error when i turn it off:
:app:transformClassesWithDexForRelease
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> 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 '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
I tried to change the buildToolsVersion '23.0.2'
to every possible version and nothing changed.
when i put the version 22.0.1 i got this error:
Error:Error converting bytecode to dex:
Cause: com.android.dx.cf.iface.ParseException: name already added: string{"a"}
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> 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 '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
I tried with all possible support libraries version and same result.
I tried with Java 1.6 and 1.7 and nothing has changed !
what can be other possible solution please ?
I also faced the same error, and i was searching through many existing answers with duplicate dependencies or multidex etc. but none worked. (Android studio 2.0 Beta 6, Build tools 23.0.2, no multidex)
It turned out that i once used a package names which didn't match the package name that is depicted in the Manifest.
In other ParseException lines, i found out that i had files in different modules whith similiar package names/paths that possibly conflicted the dexer.
Example:
Module A: com.example.xyz.ticketing.modulea.Interface.java
Module B: com.example.Xyz.ticketing.moduleb.Enumerations.java
Module C: Has dependencies on A and B
After fixing "Xyz" to lowercase, the dexer was fine again.
How to find out:
When i looked through the output of the gradle console for the ParseExceptions that looks like this:
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: java.lang.RuntimeException: Exception parsing classes"
I scrolled close to the end of the exception. There is a part in that long exception line that actually mentions the cause:
Caused by: com.android.dx.cf.iface.ParseException: class name (at/dummycompany/mFGM/hata/hwp/BuildConfig) does not match path (at/dummycompany/mfgm/hata/hwp/BuildConfig.class)
This way i found out where to search for missmatching package names/paths
just do Build > Clean Project
Wait for Cleaning Ends and then Build > Rebuild Project
, and the error was gone. that's it.
The solution for me is to modifing the Build Gradle file. I found out, that the problem is a GC overhead (out of memory).
So I add some code to my configuration
android {
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "2g"
}
}
There is some other problem with proguard. You've to set minifyEnabled to false also.
I had a wrong package name in one of the helper class,hence I was having the error.So check all the Classes and make sure you have correct package name.
My solution was different, I was added these lines in proguard-rules.pro
-optimizationpasses 5
-overloadaggressively
-repackageclasses ''
-allowaccessmodification
Make sure to update everything from SDK manager as well.
If your targetSdkVersion is 25 or higher version and you use JDK 8 you have to add in your build.gradle file the following:
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
More info: https://stackoverflow.com/a/37294741
Removing -overloadaggressively
from my proguard-rules.pro
fixed this for me.
Alternatively, adding -useuniqueclassmembernames
also fixed it.
I tried ./gradlew clean build
, Invalidating studio cache, restarting machine. But what solved the issue is turning Instant run off
Got this issue while using the Android studio template for Login activity.
I've selected "activity" package to put my activity into.
The template in AndroidManifest.xml, instead of .activity.LoginActivity
used the .LoginActivity
thus causing the error.
If you faced this error, certainly your package in manifest differ from the others that you have set in your classes. be careful.
I ran into the same issue today and the problem was that in my Constants.java classed I have defined (by mistake)
public static final class Checkout {
.......
}
and
public static final class CHECKOUT {
......
}
In my case, there was a class that I made that I didn't use yet. So I have to delete the class or use the class.
I faced the same error. Appears that its due to renaming a package to lower case and a class had the previous case wording.
Your gradle.build file will contain
compile files('libs/httpclient-4.2.1.jar')
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
By removing this line from file.
compile files('libs/httpclient-4.2.1.jar')
It will work fine.
来源:https://stackoverflow.com/questions/35680979/error-converting-bytecode-to-dex-cause-java-lang-runtimeexception-exception-p