Android Gradle
2022/3/22 6:31:19
本文主要是介绍Android Gradle,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
自定义Gradle配置文件
1)创建自定义custom.gradle
ext { android = [ compileSdkVersion : 30, buildToolsVersion : "30.0.2", minSdkVersion : 19, targetSdkVersion : 30 ] dependencies = [ "glide" : "com.github.bumptech.glide:glide:4.11.0" ] }
2)在build.gradle中引入自定义gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. // ***************** 就是加入这个 ***************** apply from : "custom.gradle" buildscript { repositories { google() mavenCentral() } 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 } }
3)替换app/build.gradle中的内容
plugins { id 'com.android.application' } android { compileSdkVersion rootProject.ext.android["compileSdkVersion"] buildToolsVersion rootProject.ext.android["buildToolsVersion"] defaultConfig { applicationId "com.example.mycustomgradleconfigtest" minSdkVersion rootProject.ext.android["minSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"] versionCode 1 versionName "1.0" } 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.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.+' implementation rootProject.ext.dependencies["glide"] }
这篇关于Android Gradle的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-01-18android.permission.read_media_video
- 2024-01-18android_getaddrinfo failed eai_nodata
- 2024-01-18androidmo
- 2024-01-15Android下三种离屏渲染技术
- 2024-01-09Android 蓝牙使用
- 2024-01-06Android对接华为AI - 文本识别
- 2023-11-15代码安全之代码混淆及加固(Android)
- 2023-11-10简述Android语音播报TTS
- 2023-11-06Android WiFi工具类
- 2023-07-22Android开发未来的出路