简体   繁体   English

Android Studio中的Gradle同步错误

[英]Gradle Syncing error in android studio

I am new in android studio after installation I have a warning of 安装后我是android studio中的新手,我有一个警告

Error:(13, 0) Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 错误:(13,0)在org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler类型的对象上找不到参数[目录'libs']的方法compile()。

Anyone please Help me to solved out. 任何人请帮助我解决。

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar']) // <-- giving warning on that line
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.android.gms:play-services:6.5.+'
}

You probably don't have the libs directory. 您可能没有libs目录。 I recommend removing that line. 我建议删除该行。 This is used to drop JARs or AAR files directly into your project. 这用于将JAR或AAR文件直接拖放到您的项目中。 This is poor practice other then when using some of the Google Maps services. 除使用某些Google Maps服务外,这是一种不好的做法。

You should reference dependencies via url and maven or ivy, not local file tree if you can avoid it. 如果可以避免,您应该通过url和maven或ivy引用依赖关系,而不是本地文件树。

Secondly, if you really want, you can go make a directory libs. 其次,如果您确实需要,可以创建目录库。 Lastly, I would ask how you get this error? 最后,我想问一下您如何得到此错误? Gradle Sync, Android Studio Build, or terminal assembleRelease. Gradle Sync,Android Studio构建或终端assembleRelease。

But the above should square you away. 但是以上内容可以使您失望。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM