Android开发——导入旧工程“ERROR: Plugin with id ‘com.android.application‘ not found.“

   记录一下导入《从零基础到APP上线》工程遇到的问题。

   例程:《junior》。

   原例程平台:Android Studio 2.2.3    ,SDK为Android7.1.1(API25)和25.0.1版本的编译工具。

   现平台:Android Studio 3.5.2。

   一,直接导入工程遇到一下问题.

   ERROR: Plugin with id 'com.android.application' not found.

旧工程只有Module的build.gradle、没有Project的build.gradle;

网上给出解决方法;

1、找一个可以正常编译的项目或新建一个项目,把Project中的build.gradle中的代码复制一下,如下图;

2、粘贴到这个报错项目的build.gradle中,放在最下面即可,下面代码;

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //testimplementation 'junit:junit:4.12'//单元测试相关可以屏蔽
    //compile 'com.android.support:appcompat-v7:28.0.3'
    implementation 'com.android.support:appcompat-v7:28.0.0'//查找当前电脑中存在的库版本号
}
buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

3,编译工程,出现一下错误。

4,根据提示,双击“Install Build Tools 27.0.3 and sync project”,安装 “Build Tools 27.0.3”。

5,安装之后编译如下。

6,根据提示进行关键词替换。

提示“Configuration 'compile' is obsolete and has been replaced with 'implementation'.”

替换关键词之后。还剩一个问题。

The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.

看起来是Gradle Plugin 3.1.0版本高了,得version (27.0.3)以上才支持。

7,在文件中屏蔽掉“BuildToolsversion 25.0.2”,再编译就没问题了,应该是用了系统中别的版本的编译工具。

8,我的电脑配置成功的文件。注意:在网页直接复制到Android studio好像有问题。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28        //SDK 版本
    buildToolsVersion "28.0.3"  //buildTools 版本

    defaultConfig {
        applicationId "com.example.junior"//
        minSdkVersion 22       //最小支持SDK版本
        targetSdkVersion 28    //目标安装的SDK版本
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //testimplementation 'junit:junit:4.12'                 //单元测试相关可以屏蔽    
    implementation 'com.android.support:appcompat-v7:28.0.0'//当前电脑中存在的库版本号
}
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        jcenter()

    }
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值