导入项目时遇到的plugin with id com.android.application not found问题解决方案
2017-09-08 10:33
751 查看
出现这个问题主要是因为缺少build.gradle文件导致的。因为一般项目会有两个build.gradle文件。其作用如下:
该文件是整个工程编译的全局文件,优先级最高
源码如下:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
从上述的注释可以看出该文件的作用:
1. 编译工程最顶级的文件,优先级最高;
2. 指定maven仓库地址,gradle相关的包是从maven拉取下来的;
3. 指定 classpath,不然无法找到某些类,标题出现的问题就是这个原因。
该文件是某个Module编译时候用到的文件
源码如下:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
这里面的配置都是大家耳熟能详的了,重点看看第一行,apply plugin: ‘com.android.application’ 表示当前Module是可执行工程。 然而找不到这个插件,原因就是 com.android.application 来源于 com.android.tools.build:gradle:2.2.0 。 这下估计都明白了!
将build.gradle里面的配置脚本拷贝到Module下的 build.gradle里面,也就是下面的脚本:
并且新建一个gradle.properties文件,并加上一句android.overridePathCheck=true,然后再重新编译即可
build.gradle(Project: xxxx)
该文件是整个工程编译的全局文件,优先级最高 源码如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules. // 优先级最高的build文件,先于Module的build.gradle执行 buildscript { repositories { jcenter() //指定maven镜像,下同 } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' //指定classpath // 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 //指定clean的时候清除掉指定目录 }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
从上述的注释可以看出该文件的作用:
1. 编译工程最顶级的文件,优先级最高;
2. 指定maven仓库地址,gradle相关的包是从maven拉取下来的;
3. 指定 classpath,不然无法找到某些类,标题出现的问题就是这个原因。
build.gradle(Module: xxx)
该文件是某个Module编译时候用到的文件 源码如下:
//注意:Gradle是通过插件来区分是可执行的工程还是libiary工程,下面表示可执行工程 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "mashen.graphicsdemo" minSdkVersion 17 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
这里面的配置都是大家耳熟能详的了,重点看看第一行,apply plugin: ‘com.android.application’ 表示当前Module是可执行工程。 然而找不到这个插件,原因就是 com.android.application 来源于 com.android.tools.build:gradle:2.2.0 。 这下估计都明白了!
解决方案:
将build.gradle里面的配置脚本拷贝到Module下的 build.gradle里面,也就是下面的脚本:buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' //注意:更换成自己的AS的版本 } } allprojects { repositories { jcenter() } }
并且新建一个gradle.properties文件,并加上一句android.overridePathCheck=true,然后再重新编译即可
相关文章推荐
- android studio导入项目报错Plugin with id 'com.android.application' not found.解决
- 解决导入项目提示Plugin with id 'com.github.dcendents.android-maven' not found.
- Plugin with id 'com.android.application' not found 问题解决方法
- 尴尬,AS导入网络下载的demo不会打开运行+++Plugin with id 'com.android.application' not found错误解决
- 关于导入moudle遇到的错误Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found解决办法
- 导入android studio 项目错误:Error:(1, 0) Plugin with id 'com.android.application' not found
- (Plugin with id com.android.application not found)问题解决
- Error:(1, 0) Plugin with id 'com.android.application' not found的解决方法
- Android stduio之Plugin with id 'com.android.application' not found解决办法
- Android Studio导入工程报错[Plugin with id 'com.android.application' not found]
- 关于Plugin with id 'com.github.dcendents.android-maven' not found.问题解决
- Android Studio导入工程报错[Plugin with id 'com.android.application' not found]
- android 编译错误 Error:(1, 0) Plugin with id 'com.android.application' not found. 解决
- 解决android studio错误 : Error:(1, 0) Plugin with id 'com.android.application' not found
- Plugin with id 'com.android.application' not found. 解决
- 解决android studio错误 --> Error:(1, 0) Plugin with id 'com.android.application' not found
- Android Studio导入工程报错[Plugin with id 'com.android.application' not found]
- android 编译错误 Error:(1, 0) Plugin with id 'com.android.application' not found. 解决
- Android Studio导入工程报错[Plugin with id 'com.android.application' not found]
- Android Studio导入工程报错[Plugin with id 'com.android.application' not found]