找不到在多模块项目的根本方法,机器人() [英] Could not find method android() in root of multimodule project

查看:98
本文介绍了找不到在多模块项目的根本方法,机器人()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试添加并行构建了一套机器人项目

有关根 build.gradle 我加了<一href="https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.enide.editors.gradle/docs/android/build.gradle"相对=nofollow>从模板

 的子项目{
    安卓{
        // {经典Android的Eclipse项目
        sourceSets {
            主要 {
                manifest.srcFile的Andr​​oidManifest.xml
                java.srcDirs = ['src'中]
                resources.srcDirs = ['src'中]
                aidl.srcDirs = ['src'中]
                renderscript.srcDirs = ['src'中]
                res.srcDirs = ['水库']
                assets.srcDirs = ['资产']
            }

            //移动测试,测试/ java中,测试/ RES等...
            androidTest.setRoot(测试)

            //将建设各类建设类型/&LT;类型&GT;
            //例如,构建类型/调试/ java中,构建类型/调试/ AndroidManifest.xml中,...
            //这会将他们从src下他们默认位置/&LT;类型&GT; / ...这将
            //与SRC /冲突正在使用的主要来源集中。
            //添加新的构建类型或产品的口味应附有
            //通过类似定制。
            debug.setRoot(集结类型/调试)
            release.setRoot(集结类型/释放)
        }
        //}
    }
}
 

但遇到错误找不到方法的Andr​​oid()...

  14:14:57.016 [错误] [org.gradle.BuildExceptionReporter]失败:建立失败,一个例外。
14:14:57.016 [错误] [org.gradle.BuildExceptionReporter]
14:14:57.017 [错误] [org.gradle.BuildExceptionReporter] *其中:
14:14:57.017 [错误] [org.gradle.BuildExceptionReporter]构建文件'D:\工作区\ WS \项目的\ src \ build.gradle'行:21
14:14:57.017 [错误] [org.gradle.BuildExceptionReporter]
14:14:57.017 [错误] [org.gradle.BuildExceptionReporter] *出了什么问题:
14:14:57.018 [错误] [org.gradle.BuildExceptionReporter]时出现问题评估根项目SRC。
14:14:57.018 [错误] [org.gradle.BuildExceptionReporter] GT;找不到方法的Andr​​oid()对根工程SRC参数[build_rp8mi2jisvr8vhjtgpkks742o $ _run_closure1_closure2 @ 6f762bb。
14:14:57.018 [错误] [org.gradle.BuildExceptionReporter]
 

我必须每个模块中复制粘贴这样的配置?
有没有办法来配置从一个根集的Andr​​oid项目的 build.gradle

类似于<一href="http://stackoverflow.com/questions/22390270/could-not-find-property-android-on-root-project">Could没有找到根项目物业'机器人'没有code,在根目录下。

用于版本:

 &GT;摇篮-v

-------------------------------------------------- ----------
摇篮1.10
-------------------------------------------------- ----------

建造时间:2013年12月17号9时28分15秒UTC
版本号:无
修订:36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:在1.8.6
蚂蚁:Apache Ant的(TM)版本1.9.2编译于2013年7月8日
常春藤:2.2.0
JVM:1.8.0_05公司(Oracle Corporation 25.5-B02)
操作系统:Windows 7 6.1 AMD64
 

解决方案

您首先需要申请在子项目机器人插件

When trying to add parallel build for set of Android projects

For root build.gradle I added from template

subprojects {
    android{
        //{ for classic Android Eclipse project
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }

            // Move the tests to tests/java, tests/res, etc...
            androidTest.setRoot('tests')

            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
        //}
    }
}

But got error Could not find method android() ...

14:14:57.016 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:14:57.016 [ERROR] [org.gradle.BuildExceptionReporter]
14:14:57.017 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
14:14:57.017 [ERROR] [org.gradle.BuildExceptionReporter] Build file 'D:\Workspaces\ws\project\src\build.gradle' line: 21
14:14:57.017 [ERROR] [org.gradle.BuildExceptionReporter]
14:14:57.017 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
14:14:57.018 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'src'.
14:14:57.018 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find method android() for arguments [build_rp8mi2jisvr8vhjtgpkks742o$_run_closure1_closure2@6f762bb] on root project 'src'.
14:14:57.018 [ERROR] [org.gradle.BuildExceptionReporter]

Do I have to copy-paste such configuration in every module?
Is there way to configure set of android project from one root build.gradle?

Similar to Could not find property 'android' on root project there is no code at root level.

Used versions:

>gradle -v

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------

Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Windows 7 6.1 amd64

解决方案

You first need to apply the android plugin inside subprojects.

这篇关于找不到在多模块项目的根本方法,机器人()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆