我想在android studio中添加一个lib,但无法正常工作.这是屏幕截图
我也试图在gradle.build中添加一个依赖项,但这也行不通.也许是因为我落后于代理人了?
解决方案
您使用了错误的 build.gradle 文件.
您不能在顶级文件中使用 compile .使用 module/build.gradle .
< PROJECT_ROOT> \ app \ build.gradle 是特定于应用程序模块的.
< PROJECT_ROOT> \ build.gradle 是顶级构建文件" ,您可以在其中添加所有子项目/模块共有的配置选项./p>
此外,您还应该将库包含在 dependencies 块中,而不是在 buildscript 块中.
顶级文件示例:
buildscript {储存库{jcenter()}依赖项{classpath'com.android.tools.build:gradle:2.3.0'classpath'com.google.gms:google-services:3.0.0'}}在 app \ build.gradle 中,您仅定义模块的属性:
apply插件:"com.android.application"安卓 {compileSdkVersion ...buildToolsVersion ...}依赖项{//..... 这里 !}I want to add a lib in android studio but it is not working. Here is a screenshot
I also tried to add a dependency in the gradle.build but that also does not work. Maybe it is because I am behind a proxy ?
解决方案You are using the wrong build.gradle file.
You can't use compile in the top-level file. Use the module/build.gradle.
<PROJECT_ROOT>\app\build.gradle is specific for app module.
<PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
Also you should include the libraries in the dependencies block, not inside the buildscript block.
Top level file example:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.0.0' } }In the app\build.gradle you define only the properties for the module:
apply plugin: 'com.android.application' android { compileSdkVersion ... buildToolsVersion ... } dependencies { //..... HERE ! }
更多推荐
找不到方法compile()
发布评论