AS报错“Plugin with id 'com.android.application' not found”

来源:互联网 发布:南美洲最发达国家知乎 编辑:程序博客网 时间:2024/06/05 19:10

  导入下载的AS项目时经常会遇到“Plugin with id ‘com.android.application’ not found”的报错。出现这个情况是因为项目缺少了一个build.grade。com.android.application来源于com.android.tools.build:gradle:2.3.0(版本可能不同)。而com.android.tools.build:gradle:2.3.0在build.grade(Project**)中定义。

这里写图片描述

  一般的gradle文件是分为项目和模块两个的。Android的工程结构是以项目为基础,可以添加多个模块。

build.grade(Project**)

buildscript {    repositories {        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:2.3.0'//这里是你的AS版本        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        jcenter()//maven仓库地址    }}task clean(type: Delete) {    delete rootProject.buildDir}

build.grade(Module**)

apply plugin: 'com.android.application'android {    compileSdkVersion 23    buildToolsVersion "23.0.0"    defaultConfig {        applicationId "locating.indoor.autonavi.com.onlinelocationdemo"        minSdkVersion 18        targetSdkVersion 23        versionCode 1        versionName "1.0"        ndk {            abiFilter "armeabi"        }    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    sourceSets {        main {            jniLibs.srcDirs = ['libs']        }    }}dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:appcompat-v7:23.0.0'}

  遇到这种情况把build.grade(Project**)中的代码复制到build.grade(Module**)中然后TryAgain就可了。注意不要忘记更改自己的AS版本。

阅读全文
0 0
原创粉丝点击