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


                                      
                    版权声明:本文为博主原创文章,转载请注明出处。                    https://blog.csdn.net/qq_34564357/article/details/78347180                
                                            
                            
                            
                             导入下载的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
}

12345678910111213141516171819202122

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'
}123456789101112131415161718192021222324252627282930313233

遇到这种情况把build.grade(Project**)中的代码复制到build.grade(Module**)中然后TryAgain就可了。注意不要忘记更改自己的AS版本。
--------------------- 
作者:我就说我巨可爱吧 
来源:CSDN 
原文:https://blog.csdn.net/qq_34564357/article/details/78347180 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    //buildToolsVersion '25.0.0'
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "org.xutils.sample"
        minSdkVersion 14
        targetSdkVersion 22 // 不使用api23的动态权限策略
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        debugConfig {
            storeFile file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            signingConfig signingConfigs.debugConfig
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:recyclerview-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile project(':xutils')
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值