在不同的目录树的Andr​​oid摇篮项目编制项目项目、摇篮、不同、目录

2023-09-07 11:14:37 作者:把心掏空狠狠爱

我有一个这样的项目布局:

  MyProject的/
    项目/
        build.gradle
    build.gradle
    settings.gradle
第三方/
    ActionBarSherlock /
        actionbarsherlock /
            build.gradle
        build.gradle
        settings.gradle
 

ActionBarSherlock 目录是一个git的子模块指向ActionBarSherlock的开发分支,它包含摇篮构建文件。

MyProject的/ settings.gradle 我说:

 包括..:第三方:ActionBarSherlock:动作条
 

MyProject的/ build.gradle 补充:

 编译..:第三方:ActionBarSherlock:动作条
 

依赖部分。当我建立 MyProject的/项目摇篮组装我收到以下错误:

 >项目已具备路径'..:第三方:ActionBarSherlock:动作条'不能在项目中找到:MyProject的
 

我可以建立 ActionBarSherlock 单独使用:

  CD第三方/ ActionBarSherlock / actionbarsherlock
摇篮组装
CP建立/库/ actionbarsherlock-4.3.2-SNAPSHOT.aar ../../../MyProject/Project/libs
 

然后把它用在依赖 MyProject的/ build.gradle 的部分:

 编译文件(库/ actionbarsherlock-4.3.2-SNAPSHOT.aar)
 

现在,当我建 MyProject的/项目我收到以下错误:

 >重复的文件在APK内同一路径:AndroidManifest.xml中
 

解决方案

这谷歌集团已经从Android的SDK开发泽维尔Ducrohet一个答案。 https://groups.google.com/forum/#​​!topic/adt -dev / bPY_Un8BsBY

要报价:

  

要依赖于摇篮项目是外你的主要项目   根文件夹,你可以尝试做如下:

     

包括ABS

     

项目(:ABS)。PROJECTDIR =新的文件(/一些/路径/亲戚/或/绝对')

     

请注意,您的应用程序应使用项目(:ABS)做了相关性,因为   在摇篮路径是:ABS无论什么磁盘上的路径

I have a project layout like this:

MyProject/
    Project/
        build.gradle
    build.gradle
    settings.gradle
thirdparty/
    ActionBarSherlock/
        actionbarsherlock/
            build.gradle
        build.gradle
        settings.gradle

The ActionBarSherlock directory is a git submodule pointing to the dev branch of ActionBarSherlock which contains gradle build files.

In MyProject/settings.gradle I added:

include '..:thirdparty:ActionBarSherlock:actionbar'

and in MyProject/build.gradle added:

compile '..:thirdparty:ActionBarSherlock:actionbar'

to the dependencies section. When I build MyProject/Project with gradle assemble I get the following error:

> Project with path '..:thirdparty:ActionBarSherlock:actionbar' could not be found in project ':MyProject'

I can build ActionBarSherlock separately, using:

cd thirdparty/ActionBarSherlock/actionbarsherlock
gradle assemble
cp build/libs/actionbarsherlock-4.3.2-SNAPSHOT.aar ../../../MyProject/Project/libs

and then use it in the dependencies section of MyProject/build.gradle as:

compile files('libs/actionbarsherlock-4.3.2-SNAPSHOT.aar')

Now, when I build MyProject/Project I get the following error:

> Duplicate files at the same path inside the APK: AndroidManifest.xml

解决方案

This google group has an answer from Android SDK developer Xavier Ducrohet. https://groups.google.com/forum/#!topic/adt-dev/bPY_Un8BsBY

To quote:

To depend on a gradle project that's outside of your main project's root folder you can try to do the following:

include 'abs'

project(':abs').projectDir = new File('/some/path/relative/or/absolute')

Note that your app should do a dependency using project(':abs'), since the gradle path is :abs no matter what the on-disk path is.