14

We have recently migrated to Android Studio (from Intellij). I am currently trying to migrate our project to use gradle for builds. I have tried fitting it around our current folder structure, and I have tried to migrate our files to match the gradle file structure.

I have had errors each way, I have been looking for an answer, but can't find anything that quite matches what we are getting.

The error I get when trying to migrate to the gradle file structure is:

  • What went wrong:

    A problem occurred configuring project ':'.

    Failed to notify project evaluation listener. Configuration with name 'default' not found

The error I get using our old file structure is:

:<project>:processDebugResources
/Users/kbrown/dev/AndroidClient/<project>/build/res/all/debug/values/values.xml:311: error: Error retrieving parent for item: No resource found that matches the given name '@style/Widget.Sherlock.ActionBar.Solid'.
/Users/kbrown/dev/AndroidClient/<project>/build/res/all/debug/values/values.xml:312: error: Error: No resource found that matches the given name: attr 'background'.
/Users/kbrown/dev/AndroidClient/<project>/build/res/all/debug/values/values.xml:314: error: Error: No resource found that matches the given name: attr 'backgroundSplit'.

Any ideas on where to look. We do have a couple references to libraries like ActionBarSherlock.

build.gradle

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

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/retrofit-1.0.0-SNAPSHOT.jar')
    compile project(':ThirdParty:ActionBarSherlock')
    compile project(':ThirdParty:drag-sort-listview')
    compile project(':ThirdParty:SlidingMenu')
    compile project(':ThirdParty:Android-ViewPagerIndicator')
}


android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            resources.srcDirs = ['src']
            res.srcDirs = ['res']

        }

        instrumentTest.setRoot('../UnitTests/src')
    }
}

settings.gradle

include ':library:Android-ViewPagerIndicator',':library:SlidingMenu',':library:drag-sort-listview',':library:ActionBarSherlock',':<project>'

Any ideas would be appreciated.

hoss
  • 2,430
  • 1
  • 27
  • 42
user2449336
  • 185
  • 1
  • 2
  • 6

3 Answers3

8

You will sometimes get this error if Gradle cannot use the default project layout defined by the Android plugin. It looks like you're trying to configure your build.gradle to use the oldstyle layout, but forgot to include some directories (namely java.srcDirs). Try something like:

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

It could also be that one of your dependency projects isn't configured correctly. Do you have a build.gradle file for ActionBarSherlock and the other third party projects? Try commenting out your dependencies and re-adding them one at a time to see when the error occurs.

Greg
  • 3,731
  • 1
  • 29
  • 25
  • I had to add a gradle.build file to my ActionBarSherlock project with the sourceSets data. Solved my issue, thanks and +1 :) – Jan-Terje Sørensen Jul 08 '13 at 10:01
  • strange that eclipse wasn't generating a build.gradle file for action bar sherlock, though it did for my other 3rd party dependencies. – topwik Jul 19 '13 at 20:58
  • "Do you have a build.gradle file.." was my issue that caused this error, oops! – Zulaxia Aug 05 '13 at 07:56
2

By looking at your dependencies:

dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/retrofit-1.0.0-SNAPSHOT.jar')
compile project(':ThirdParty:ActionBarSherlock')
compile project(':ThirdParty:drag-sort-listview')
compile project(':ThirdParty:SlidingMenu')
compile project(':ThirdParty:Android-ViewPagerIndicator')
}

You should have in your settings.gradle :
include ':ThirdParty:Android-ViewPagerIndicator' .... rather than include ':library:Android-ViewPagerIndicator' ....

lukasz
  • 3,121
  • 1
  • 21
  • 20
  • Thanks to everyone for helping. I have the modified project building. I am still working on the one that follows the new directory structure. If I remove all dependencies it works. As soon as I add ActionBarSherlock I get * What went wrong: A problem occurred configuring project ':'. > Failed to notify project evaluation listener. > Configuration with name 'default' not found. – user2449336 Jun 04 '13 at 14:21
  • Here is the build for ActionBarSherlock buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android-library' dependencies { compile files('libs/android-support-v4.jar') } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 8 targetSdkVersion 16 } sourceSets { main { manifest.srcFile 'library/AndroidManifest.xml' resources.srcDirs = ['library/src'] res.srcDirs = ['library/res']}}} – user2449336 Jun 04 '13 at 14:23
  • 4
    Can you please edit your question rather than copy pasting code in the comments, it's not very clear like that – lukasz Jun 04 '13 at 15:32
  • Next time for sure. I did get this working so no need now. Thanks for the help it got me building. – user2449336 Jun 04 '13 at 16:01
  • What is the filetree structure of your project with subprojects ? – lukasz Jun 04 '13 at 16:05
  • 8
    @user2449336: the reason to edit the question is not to help you, its to help others (like me). – Cubs Fan Ron Sep 12 '13 at 14:49
0

One other potential cause of this precise error: I found this error was resolved by commenting some unused libraries in build.gradle dependencies section. Make sure these paths and such are all correct.