Android

137 阅读1分钟

1.解决构建慢的问题 在settings.gradle.kts中修改

pluginManagement {
    repositories {
        maven {
            url = uri("https://maven.aliyun.com/repository/central")
        }
        maven {
            url = uri("https://maven.aliyun.com/repository/google")
        }
        maven {
            url = uri("https://maven.aliyun.com/repository/jcenter")
        }
        google {
            content {
                includeGroupByRegex("com\.android.*")
                includeGroupByRegex("com\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
         mavenCentral()
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven {
            url = uri("https://maven.aliyun.com/repository/central")
        }
        maven {
            url = uri("https://maven.aliyun.com/repository/google")
        }
        maven {
            url = uri("https://maven.aliyun.com/repository/jcenter")
        }
        google()
        mavenCentral()
    }
}

在globle的 gradle.properties中

repositories.grails.default=https://maven.aliyun.com/repository/public
repositories.grails.default.1=https://mirrors.tuna.tsinghua.edu.cn/maven/repos/public
repositories.grails.default.2=https://repo.maven.apache.org/maven2
systemProp.http.proxyHost=
systemProp.http.proxyPort=80
systemProp.https.proxyHost=
systemProp.https.proxyPort=80

在project的 gradle.properties中最后添加

android.nonTransitiveRClass=true
systemProp.gradle.network.download.mirror=https://maven.aliyun.com/repository/gradle-plugin

真机运行

1.查看设备对应的Android版本号,在项目的设置中找到sdk plateform,下载对应的版本。在sdk tools 的tab下,下载 google usb driver。 2.登录小米账号。在设备的版本号上连续点击进入开发者模式,输入USB搜索,打开USB调试模式,打开usb安装,然后就可以在安卓studio上看到设备,点击运行后,在pad端点击继续安装。