[英]Adding external library project
I'm using android studio and i want to add an external library project to my main project from GitHub.com . 我正在使用android studio,我想从GitHub.com向我的主项目添加一个外部库项目。 I have created a folder named libs and add the whole module to it.Then like what is told in github i added this line of code to build.gradle file
我创建了一个名为libs的文件夹并向其中添加了整个模块。然后像github中所说的那样,将这行代码添加到build.gradle文件中
compile 'org.apmem.tools:layouts:1.10@aar'
But i could not build my project and received this error 但是我无法建立我的项目并收到此错误
Error:(9, 1) A problem occurred evaluating root project 'MyProject'.
错误:(9,1)评估根项目'MyProject'时出现问题。 Could not find method compile() for arguments [org.apmem.tools:layouts:1.10@aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
在类型org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象上找不到参数[org.apmem.tools:layouts:1.10@aar]的方法compile()。
After searching about this problem find a solution here and follow steps which has described there. 搜索此问题后,在此处找到解决方案,并按照此处描述的步骤进行操作。
But now i receive this error 但是现在我收到这个错误
Error:A problem occurred configuring project ':app'.
错误:配置项目':app'时发生问题。 Cannot evaluate module android-flowlayout-master : Configuration with name 'default' not found.
无法评估模块android-flowlayout-master:找不到名称为“默认”的配置。
EDIT : my build.gradle file 编辑:我的build.gradle文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
compile 'org.apmem.tools:layouts:1.10@aar'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
There are multiple build.gradle
files in Android projects. Android项目中有多个
build.gradle
文件。 There is the project level one that's in the root of your project, and then there are the module level ones, which are in the subfolders of the modules. 在项目的根目录中有一个项目级别,然后在模块的子文件夹中有模块级别的项目。 By default, you have one module in the project, called
app
. 默认情况下,项目中有一个名为
app
模块。
When you're adding dependencies, you have to add them to the module's build.gradle
file (which has the android
block on top by default), inside the dependencies
block. 当你添加依赖,你必须将它们添加到模块
build.gradle
文件(其中有android
在默认情况下顶块),里面dependencies
块。 This is what the comment in the project level build.gradle
is warning you about. 这是项目级别
build.gradle
的注释警告您。
By default, this file is in the app
folder. 默认情况下,此文件位于
app
文件夹中。 It looks like this if you're using the Android view of the project in Android Studio: 如果您在Android Studio中使用项目的Android视图,则如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.