[英]Where exactly to put gradle dependecies in Android Studio?
i created a fresh project in the Android studio and i would like to add this logging plugin. 我在Android Studio中创建了一个新项目,我想添加此日志记录插件。
https://github.com/orhanobut/logger https://github.com/orhanobut/logger
So i copied all into ProjectDirectory/app/build.gradle go get something like this. 所以我将所有内容复制到ProjectDirectory / app / build.gradle中,得到类似的内容。
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.orhanobut:logger:1.11'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
}
But after the rebuild process Android studio is still import wrong class: 但是在重建过程之后,Android Studio仍然会导入错误的类:
import java.util.logging.Logger;
So i think, that dependency was not imported correctly. 所以我认为,该依赖关系未正确导入。
How can i do it it the right way please? 我该如何正确地做呢?
The line 'com.orhanobut:logger:1.11'
assumes that you have declared a repository that hosts the artifact it identifies. 'com.orhanobut:logger:1.11'
假定您已声明一个存储它标识的工件的存储库。
If you have declared a valid repository, you've most likely been tricked by auto-import. 如果您声明了有效的存储库,则很可能会被自动导入所欺骗。 Remove the import and be sure to select the proper logger import when prompted. 删除导入,并确保在出现提示时选择正确的记录器导入。
If gradle build completed successfully without errors, then the import was completed correctly. 如果gradle构建成功完成且没有错误,则导入已正确完成。 However in your java classess, if you have 2 libraries with the same name (as in your case, there is 2 logger libraries) you can type logger
then press ctrl + space
to open a menu that lets you choose which logger library to use. 但是,在Java类中,如果有2个同名的库(如您的情况,有2个记录器库),则可以键入logger
然后按ctrl + space
打开一个菜单,让您选择要使用的记录器库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.