Android – library added: gradle build

I just updated my project with the new gradle build system

After many attempts, I always encounter the same problem

I have a project that contains many sub library projects. Those that use support-library-v4 also use it for my main project. After some search, I found that I must use the Maven link:

compile 'com.android.support:support-v4:13.0.0' 

I added this (and kept the jar in the LIBS folder for eclipse compatibility) but still had the same error

UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb;
        at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
        at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
        at com.android.dx.command.dexer.Main.processClass(Main.java:490)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
        at com.android.dx.command.dexer.Main.access$400(Main.java:67)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
        at com.android.dx.command.dexer.Main.processOne(Main.java:422)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
        at com.android.dx.command.dexer.Main.run(Main.java:209)
        at com.android.dx.command.dexer.Main.main(Main.java:174)
        at com.android.dx.command.Main.main(Main.java:91)

I even tried to delete those LIBS in the / LIBS folder, but I had no luck

I use the latest version of gradle "classpath" com. Android. Tools. Build: gradle: 0.5.4 '"but I have no luck

I hope someone has a better idea?

This is my build script:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.4'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

apply plugin: 'android'

dependencies {
    repositories {
        mavenCentral()
    }

    compile project(':HoloGraphLibrary')
    compile project(':CardsUI')
    compile project(':Caldroid')
    compile project(':BetterPickers')
    compile project(':Crouton')
    compile project(':ShowcaseView')
    compile project(':AboutLibraries')
    compile project(':StyledDialogs')

    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.android.support:support-v4:13.0.0' 
    compile 'joda-time:joda-time:2.2'
    compile files('libs/ActiveAndroid-3.3.jar') 
    compile files('libs/crashlytics.jar') 
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 17
    }

    sourceSets {

        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

This is a build script for one of my LIBS:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.4'
    }
}
apply plugin: 'android-library'

dependencies {
//     compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:support-v4:13.0.0' 
    compile 'joda-time:joda-time:2.2'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

resolvent:

Are you sure all sub libraries have this line

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

The comments come out?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>