0
点赞
收藏
分享

微信扫一扫

Android Stdio换源以及配置项目


文章目录

  • ​​换阿里源​​
  • ​​方法二(待测)​​
  • ​​换源​​

换阿里源

  1. 对特定项目生效,在项目中的​​build.gradle​​修改内容

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"

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

allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
}
}

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

  1. 对所有项目生效
    在​​​C:\Users\Administrator\.gradle​​下创建init.gradle文件

allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}

方法二(待测)

换源

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
// 资源混淆插件:https://github.com/shwenzhang/AndResGuard
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.17'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/central/' }
maven { url 'https://dl.bintray.com/getactivity/maven/' }
maven { url 'https://dl.bintray.com/umsdk/release' }
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
}
}

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

config.gradle

// 通用配置
android {

compileSdkVersion 31
defaultConfig {
minSdkVersion 16
targetSdkVersion 31
versionName '1.0'
versionCode 10
}

// 支持 Java JDK 8
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}

// 设置存放 so 文件的目录
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}

dependencies {
// 依赖 libs 目录下所有 jar 包
implementation fileTree(include: ['*.jar'], dir: 'libs')
// 依赖 libs 目录下所有 aar 包
implementation fileTree(include: ['*.aar'], dir: 'libs')

// 谷歌兼容库:https://developer.android.google.cn/jetpack/androidx/releases/appcompat?hl=zh-cn
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
implementation 'com.google.android.material:material:1.3.0-alpha01'
}

举报

相关推荐

Linux换源

linux 换源

tensorflow换源

npm换源

alpine换源

centos换源

Kali换源

0 条评论