问题描述
我有一个目录/项目设置是这样的:
C:\
_dev \
项目\
记录仪
我的项目
记录器的是采用摇篮一个Android库项目。 MyProject的的是,需要使用一个标准的Android项目工程的日志的库。
我使用Android的工作室,并尝试添加的日志的外部库。虽然这在开发过程中的工作,我得到的消息对未建的时候发现的类。
我是完全新的摇篮,但已尝试在以下我build.gradle的 MyProject的的:
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.5.+
}
}
应用插件:'机器人'
库{
mavenCentral()
}
安卓{
compileSdkVersion 18
buildToolsVersion18.1.0
defaultConfig {
的minSdkVersion 16
targetSdkVersion 18
}
依赖{
编译文件(../记录器)
}
}
依赖{
编译com.android.support:gridlayout-v7:18.0.0
编译com.android.support:appcompat-v7:18.0.0
}
嘛simpliest方法是使MyProject的与记录仪项目作为子项目多项目:
settings.gradle在MyProject的目录:
有:记录器
项目(:记录器)PROJECTDIR =文件(../记录器)。
在MyProject的的buld.gradle你现在可以参考这个LIB作为一个项目:
相关性{
编译com.android.support:gridlayout-v7:18.0.0
编译com.android.support:appcompat-v7:18.0.0
编制项目(:记录器)
}
希望帮助!
欢呼声中,
勒
I have a directory/project setup like this:
C:\
_dev\
Projects\
Logger
MyProject
Logger is an Android library project using Gradle. MyProject is a standard Android project project that needs to make use of the Logger library.
I am using Android Studio and have tried adding Logger to the external libraries. Whilst this works during development, I get messages about the class not being found when building.
I'm completely new to Gradle, but have tried the following in my build.gradle within MyProject:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 18
}
dependencies {
compile files("../Logger")
}
}
dependencies {
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
}
Well the simpliest way is to Make MyProject a multi project with the Logger project as a subproject:
settings.gradle in MyProject directory:
include ":logger"
project(":logger").projectDir = file("../logger")
in the buld.gradle of MyProject you can now reference this lib as a project:
dependencies {
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
compile project(":logger")
}
hope that helps!
cheers,
René
这篇关于从另一个目录要求摇篮工程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!