0

I have faced a unknown type of error.

here my build.grable:-

    apply plugin: 'com.android.application'

repositories {
    maven { url "https://jitpack.io" }
}
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "shoppingmazza.android.catalyst.com.shoppingmazza"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile files('libs/fluent-hc-4.5.jar')
    compile files('libs/httpclient-4.5.jar')
    compile files('libs/httpclient-cache-4.5.jar')
    compile files('libs/httpclient-win-4.5.jar')
    compile files('libs/httpcore-4.4.1.jar')
    compile files('libs/httpmime-4.5.jar')
    compile files('libs/jna-4.1.0.jar')
    compile files('libs/jna-platform-4.1.0.jar')
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.squareup.picasso:picasso:2.3.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile files('libs/commons-net-3.0.1.jar')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
}

and here my logcat:-

    Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareComDaimajiaSliderLibrary115Library UP-TO-DATE
:app:prepareComGithubJakeWhartonViewPagerIndicator241Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    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)
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_51\bin\java.exe'' finished with non-zero exit value 2

I am new in android developing.Anyone can help me solved my problem. I near my to complete project. Please help me. Thanks in advance!

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841

4 Answers4

0

Add this inside your android block:

dexOptions {
    preDexLibraries = false
}
Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58
0

Your project methods is over 65k. You should implement Multidex

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30
  • after implement Mutidex `:app:packageAllDebugClassesForMultiDex FAILED Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl.class` i found this error. –  Dec 01 '15 at 14:48
  • Some of your libraries are using android support v4 library with different versions. We need to find them out :( – Emre Aktürk Dec 01 '15 at 14:52
  • And our solution should be like http://stackoverflow.com/questions/30727582/gradle-duplicate-entry – Emre Aktürk Dec 01 '15 at 14:52
0

if your project has more than 65K method , you have to enable multiDex option in gradle ,, to make sure if the problem caused by multiDex ,, just run your app on a lolipop device if it running fine , then the problem is MultiDex ,

lolipop doesn't use Dalvik thats why it will running fine

S. Alawadi
  • 144
  • 1
  • 6
0
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

You are adding twice the support-library v4.

It happens because you are using

compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'

You are getting this library from the jitpack.
This library adds the support library as a jar and not as a gradle dependency.

It means that the pom file doesn't have a dependency and you can't exclude the jar file with gradle because the jar is inside the aar file (without a pom how can gradle know that these files should be excluded?).

You can check the files in the jitpack repo:

You can try to use the same library from other repo, for example:

`fr.avianey.com.viewpagerindicator:library:2.4.1`

You can check this issue on github.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841