Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
144 views
in Technique[技术] by (71.8m points)

android - Problems trying to create gradle build

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...