0

I updated Android Studio to latest version. Now i can compile my app as debug but when i try to deploy on a device or generate a signed apk gives me following errors:

Error:Execution failed for task ':ribony:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:compiler that did not target the modern .class file format. The recommended
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:(org.xbill.DNS.UDPClient$1) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:indicate that it is *not* an inner class.
Error:this warning is that reflective operations on this class will incorrectly
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:compiler that did not target the modern .class file format. The recommended
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:(jnamed$3) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:compiler that did not target the modern .class file format. The recommended
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:(jnamed$2) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:indicate that it is *not* an inner class.
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:compiler that did not target the modern .class file format. The recommended
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:(jnamed$1) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class

My gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.impact.ribony"
        minSdkVersion 14
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile project(':ion')
    compile project(':lib_PagerSlidingTabStrip')
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.google.android.gms:play-services-base:8.3.0'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile 'com.google.android.gms:play-services-ads:8.3.0'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.chrisbanes:PhotoView:1.3.1'
    compile files('libs/android-viewbadger.jar')
    compile files('libs/circleimageview-1.2.2-javadoc.jar')
    compile files('libs/circleimageview-1.2.2-sources.jar')
    compile files('libs/circularimageview-1.1-javadoc.jar')
    compile files('libs/dnsjava-2.1.6.jar')
    compile files('libs/engine.io-client-0.4.1.jar')
    compile files('libs/Java-WebSocket-1.3.0.jar')
    compile files('libs/json-org.jar')
    compile files('libs/socket.io-client-0.4.1.jar')


}

I guess problem is with same this link: Large number of errors during Gradle build after upgrading to Android Studio 2.0

To resolve this problem i wanted to add

-keepattributes EnclosingMethod

This line to proguard-rules.txt file. ı couldn't find the file then i created this file by manually at root of my project and I put the line to this file. And nothing changed. Then I found the proguard-android.txt in Android sdk path. Then added the same line to this file. Then i tried to generate signed apk and again same errors.

How can I resolve this problem?

Community
  • 1
  • 1
Tolgay Toklar
  • 3,467
  • 7
  • 35
  • 56
  • Your real problem is `Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;`. You are pulling in two copies of this class, through two separate dependencies, in some way that Gradle cannot automatically resolve. – CommonsWare Nov 22 '16 at 19:20
  • Hmm, do you have an idea for resolve? Becase i wasn't experiencing this problem with old version of Android Studio – Tolgay Toklar Nov 22 '16 at 19:21
  • Look inside each of those JARs (and any JARs those library modules might have) and see which of those contains stuff in the `android.support` package. – CommonsWare Nov 22 '16 at 19:28
  • I found one. http://prntscr.com/daj96h But when i remove the android.support line my project is not compiling becase i am getting v4.support class is not found. What do i have to do? – Tolgay Toklar Nov 22 '16 at 19:57
  • That wasn't a JAR. Anyway, you can run a Gradle dependencies report to see whether Gradle is upgrading Ion's(?) use of `support-v4` from 19 to 23. If it is not, then you might need to force that yourself. If, on the other hand, Gradle is correctly forcing Ion to use the newer dependency, then that is not where your problem lies. JARs are a more likely candidate. – CommonsWare Nov 22 '16 at 20:09
  • I removed all jars from my project but still getting two same errors. My gradle file: http://prntscr.com/dak6hc Errors: http://prntscr.com/dak771 Do you have an idea? – Tolgay Toklar Nov 22 '16 at 21:04
  • Run a [Gradle dependency report](https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:listing_dependencies) and see if you are getting 2+ versions of the Android support libraries. – CommonsWare Nov 22 '16 at 21:05
  • Don't know why but i updated v4 library to v25 (also updated compileSdk to v25) and problem disappeared. – Tolgay Toklar Nov 22 '16 at 21:44

0 Answers0