[英]How can I use an application from another project as a library?
How can I use an application from another project as a library, when that application depends on a library that I am already using? 当另一个项目的应用程序依赖于我已经在使用的库时,我该如何将该应用程序用作库?
Here's what I have: 这是我所拥有的:
MyProject
app
libraries
ExoPlayer
demo
library
Here's my current configuration as it pertains to this. 这是我当前与此相关的配置。
demo/build.gradle: demo / build.gradle:
apply plugin: 'com.android.application'
...
dependencies {
compile project(':library')
}
library/build.gradle: 库/ build.gradle:
apply plugin: 'com.android.library'
MyProject/settings.gradle: MyProject / settings.gradle:
include ':libraries:ExoPlayer:library'
MyProject/app/build.gradle: MyProject / app / build.gradle:
dependencies {
compile project(':libraries:ExoPlayer:library')
}
As you can see I'm using ExoPlayer library as a library (go figure) but I want to use demo application as a library as well (specifically for the DemoPlayer, I don't want the activities). 如您所见,我将ExoPlayer库用作库(如图),但我也想将演示应用程序用作库(特别是对于DemoPlayer,我不希望有活动)。 But demo also has a dependency on library.
但是demo也依赖于库。 What do I have to put in my gradle files to achieve this?
要实现此目的,我必须在gradle文件中放入什么?
I tried to follow the library setup and apply it to demo but it broke the demo build: 我尝试遵循库设置并将其应用于演示,但它破坏了演示版本:
Project with path ':library' could not be found in project ':libraries:ExoPlayer:demo'
I have tried following other similar threads such as this one but with no success. 我曾尝试遵循其他类似的线程,例如这个,但没有成功。
I appreciate any help. 感谢您的帮助。
A long time ago I've use Exoplayer as a library project but it's not needed anymore : you can use gradle dependencies : 很久以前,我已经将Exoplayer用作库项目,但是不再需要它:您可以使用gradle依赖项:
compile 'com.google.android.exoplayer:exoplayer:r1.4.2'
If you want to persist with library project, you will have to check your settings.gradle
where all Android Studio referenced module are in. This file contain the name of module as you will use it after. 如果要继续执行库项目,则必须检查所有Android Studio引用模块所在的位置的
settings.gradle
。此文件包含模块名称,以后将使用它。
Example : (based on AndroidVuMeter ) 示例 :(基于AndroidVuMeter )
settings.gradle settings.gradle
include ':app', ':vumeterlibrary'
project structure 项目结构
Project/
app/
vumeterlibrary/
To use vumeterlibrary
you will have to use compile project(':vumeterlibrary')
in your app build.gradle
要使用
vumeterlibrary
您必须在应用程序build.gradle
使用compile project(':vumeterlibrary')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.