简体   繁体   中英

Android support v4

I have problem in my project. When I'm trying to build my project this error apears in logs:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
  /Users/pawelkoperdowski/Documents/Android/sdk/build-tools/22.0.1/dx --dex --no-optimize --output /Users/pawelkoperdowski/Documents/Android/Superplanner/superplanner-android/app/build/intermediates/dex/debug --input-list=/Users/pawelkoperdowski/Documents/Android/Superplanner/superplanner-android/app/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
  2
  Output:
  UNEXPECTED TOP-LEVEL EXCEPTION:
  com.android.dex.DexException: Multiple dex files define Ljavax/inject/Provider;
  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)

So I've read in one of questions here that I should add this to my gradle file:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

But now in classes which use suport I have this errors like this:

Error:(21, 33) error: package android.support.v4.widget does not exist

My gradle file:

apply plugin: 'com.android.application'
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    defaultConfig {
        applicationId 'pl.essentialapps.superplanner'
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/2'] } }
}

repositories {
    maven {
        url "https://mint.splunk.com/gradle/"
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/jsr305-1.3.9.jar')
    compile project(':facebook')
    compile files('libs/guava-18.0.jar')
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:6.+'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile 'com.splunk.mint:mint:4.0.5'
    compile 'joda-time:joda-time:2.6'
    compile 'com.baoyz.pullrefreshlayout:library:1.0.1'
    compile 'org.roboguice:roboguice:3.+'
    provided 'org.roboguice:roboblender:3.+'
    compile 'com.android.support:support-v4:22.1.0'
}

I will be very thankfull for any help :)

I recommend you to update the build.gradle :

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:27.1.1'

compile 'com.android.support:design:27.1.1'

All fields containing 'com.android.support' should end in 27.1.1 (replace 22.0.0 or 22.1.0 as i see in your program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM