使用IDEA2021.2创建Android项目遇到的问题

一、Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

直接降版本,使用api30
在这里插入图片描述
然后修改build.gradle中的三处代码
在这里插入图片描述
注意buildToolsVersion要30.0.2
之前使用30.0.0报错如下:

The specified Android SDK Build Tools version (30.0.0) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.0.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove “buildToolsVersion ‘30.0.0’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

大致意思就是当前gradle支持的最低版本是30.0.2;
再去项目结构中修改SDKs,把api30加进去
在这里插入图片描述
修改完点击这里立即同步,就会重新build
在这里插入图片描述

二、Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.

This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: root project ‘My Application’, project ‘:app’

这个意思就是jcenter不能用了。。
在这里插入图片描述
看这个warning就知道了
所以给gradle配置阿里云镜像即可
在build.gradle中,buildScript和allProjects中的repositories,改为以下代码

mavenLocal()    //使用本地maven仓库
//阿里云Maven镜像
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
mavenCentral()     //使用maven中心仓库

可以参考阿里云maven仓库指南https://developer.aliyun.com/mvn/guide
以下是我完整的build.gradle内容

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        /*google()
        mavenCentral()*/
        mavenLocal()    //使用本地maven仓库
        //阿里云Maven镜像
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        mavenCentral()     //使用maven中心仓库
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.0"

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

allprojects {
    repositories {
        /*google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon*/
        mavenLocal()    //使用本地maven仓库
        //阿里云Maven镜像
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        mavenCentral()     //使用maven中心仓库
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

三、This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints

意思就是没有添加约束,因为我们使用的是constraintlayout,没有约束的话一些控件会跳转到(0,0)的位置
在这里插入图片描述
点击这个魔法棒就可以了

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值