安卓11开发 错误 编译 gradle 版本问题

最近开发安卓11,构建老是出各种各样问题,总结一下,基本都是版本问题,要严格遵循版本对应,一不对应就会出问题
本机成功版本记录一下
AS 4.2.2 用 6.4.1 其实AS还是有点高了,建议再降,附上l历史版本下载地址,选英文版,中文会看不到
https://

developer.android.google.cn/studio/archive

gradle 下载比较慢,建议自己下载好,停止as下载,用file 替换http协议 url,之后在项目根目录运行gradlew

下载地址

测试腾讯云地址快一些
https://

mirrors.cloud.tencent.com/gradle/
阿里云下载地址
https://
mirrors.aliyun.com/macports/distfiles/gradle/

android studio 版本Android Studio 4.2.2

Build #AI-202.7660.26.42.7486908, built on June 24, 2021
Runtime version: 11.0.8+10-b944.6842174 amd64
VM: OpenJDK 64-Bit Server VM by N/A
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 4
Registry: external.system.auto.import.disabled=true

local.properties

中配置

android.useAndroidX=true
android.exported=“true”

gradle 版本 gradle-6.4.1

gradle\wrapper\gradle-wrapper.properties 中

distributionUrl=file:///D:/download/gradle-6.4.1-bin.zip

build.gradle 中 插件版本4.0.2

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { name “Alibaba” ; url ‘https://maven.aliyun.com/repository/public’ }
maven { name “Bstek” ; url ‘https://nexus.bsdn.org/content/groups/public/’ }
maven { name “M2” ; url ‘https://plugins.gradle.org/m2/’ }
google()
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:4.0.2’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven { name “Alibaba” ; url “https://maven.aliyun.com/repository/public” }
maven { name “Bstek” ; url “https://nexus.bsdn.org/content/groups/public/” }
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

\app\build.gradle 中SDK配置

plugins {
id ‘com.android.application’
}

android {
compileSdkVersion 30
buildToolsVersion “30.0”

defaultConfig {
applicationId “com.xxxx.myapplication”
minSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName “1.0”

// testInstrumentationRunner “androidx.test.runner.AndroidJUnitRunner”
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt’), ‘proguard-rules.pro’
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation ‘androidx.appcompat:appcompat:1.2.0’
implementation ‘com.google.android.material:material:1.2.1’
implementation ‘androidx.constraintlayout:constraintlayout:2.0.1’
// testImplementation ‘junit:junit:4.+’
// androidTestImplementation ‘androidx.test.ext:junit:1.1.2’
// androidTestImplementation ‘androidx.test.espresso:espresso-core:3.3.0’
}

  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值