5

Here is the content of my build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
   maven {
        credentials {
            username artifactoryUserName
            password artifactoryPassword
        }

        url 'http://test:8081/artifactory/libs-release-local'
    }
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.1.0'
}
allprojects {
repositories {
    maven {
        credentials {
            username artifactoryUserName
            password artifactoryPassword
        }
        url 'http://test:8081/artifactory/libs-release-local'
    }
    mavenCentral()
    maven { url 'http://repo1.maven.org/maven2' }
    jcenter()
} }

Here is the content of app\build.gradle:

    apply plugin: 'com.android.application'
    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId "test.com"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {

        aseeConfig {
            storeFile file("test.keystore")
            storePassword "test123"
            keyAlias "AndroidKey"
            keyPassword "test123"
        }

    }

    buildTypes {
        release {
            signingConfig signingConfigs.aseeConfig
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        prod.initWith(buildTypes.release)
        prod {
            signingConfig signingConfigs.aseeConfig
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    } }

    dependencies {
    //compile 'com.google.android:support-v4:r13'
    compile 'com.google.android:google-play-services:4.1.32'
    compile 'com.devsmart.android:devsmart-lib:1.0.0'
    compile 'com.jeremyfeinstein.slidingmenu.lib:sliding-menu:1.0.0'
    compile 'com.viewpagerindicator:viewpager-indicator:2.4.1'
    ///compile 'com.google.android.gms:google-play-services_lib:4.1.32'
    compile 'com.emilsjolander:sticky-list-headers:1.0.0'
    //compile 'com.actionbarsherlock:actionbar-sherlock:4.2.0'
    compile 'com.mobeta.android.dslv:drag-sort-list-view:0.6.1'
    compile 'com.threegvision.products:inigma_sdk_pro:3.24'

    compile 'org.afree:a-free-chart:1.0.0'
    compile 'org.afree:a-free-graphics:1.0.0'
    compile 'net.simonvt:datepicker:1.0'
    //compile 'eu.inmite:android-styled-dialogs:1.1'
    compile 'com.nineoldandroids:nine-old-androids:2.4.1'

    compile 'com.shinobicontrols.charts:shinobicharts:1.5.0-5'
    compile 'com.squareup.picasso:picasso:2.3.2'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.github.bumptech.glide:glide:3.6.0'
    compile 'com.journeyapps:zxing-android-embedded:3.0.1@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/actionbarsherlock-4.2.0.jar')
    compile files('libs/android-styled-dialogs-1.1.1-sources.jar')
    compile files('libs/android-support-4.0.jar')
}

I can't build my project . I am getting this error:

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
vikifor
  • 3,426
  • 4
  • 45
  • 75
  • Some people noticed this, when they had dashes - in their filenames. Additionally Build Tools v21 seems to make problems in Windows. Try updating them. – Sbls Jul 26 '15 at 10:32
  • Does build tools version have to be the same as sdk version? I am having two versions of build tools installed v21 an v22. Can these make a problem? – vikifor Jul 26 '15 at 10:40
  • I have two installed as well. (But I'm on linux, and I don't have v21.0). Try uninstalling v21. – Sbls Jul 26 '15 at 10:44
  • I uninstalled v21, but I still have the same problem do you have some another idea? – vikifor Jul 26 '15 at 16:06
  • 1
    Try build->clean then build->rebuild. If that doesn't help try `./gradlew assembleDebug --info` to get more information. – Sbls Jul 26 '15 at 16:54
  • You need to isolate the task that is erroring. aapt.exe returning a non-zero exit code could be ALOT of things. Additionally, the gradle script defines it's own buildTypes so I try this: ./gradlew.bat assembleRelease --info --stacktrace and add the results to your question. – PaulR Jul 29 '15 at 18:40

3 Answers3

0

I faced this kind of issue once but I don't remember exactly how to fix it.
As I rememeber, I follow this link
It's seem because there are many module dependent on difference support-v4 lib. So add multiDexEnabled true may works.

Also try to set all modules' dependency to a same version of support-v4. You can look at these link to known how to exclude compile v4 link1 link2 link3
If it still doesn't work, try to clean project, restart Studio, even restart your computer(I don't know why but this worked for me once)

Hope this helps.

Community
  • 1
  • 1
justHooman
  • 3,044
  • 2
  • 17
  • 15
0

Generally, it is because of resource conflicts within your modules.For sample, there are two ic_launcher.png in your app.(one from module and one from your app)

I searched to check resource conflicts but I didn't find official solution.

I only solved by this ways, remove each module and test it is being conflict or not. That's the simplest way to solve. I hope this will help you.

Here below are another suggestion....

I found also this way, one person(I didn't remember name) use safe delete to check conflict.

And some Q&A said, to add multiDexEnabled:true. That config is to increase dex file size. You can also use multidex support library .

The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

Here is the link for multiDex:
https://developer.android.com/tools/building/multidex.html

But documentation said you should be careful to use that.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Hein Htet Aung
  • 844
  • 4
  • 16
0

in your build.gradle file set your compileSdkVersion 20.0.0 and buildToolsVersion "21.0.0"

Darshan Mistry
  • 3,294
  • 1
  • 19
  • 29
  • have you tried to set different build tool version and compile sdk version and also compile latest version of google play service 7.0+ in dependencies section. – Darshan Mistry Aug 03 '15 at 05:27