android app开发记录1

因为公司需要,所以起一个android项目,这里用来记录开发过程。

第一步使用idea创建android项目,必须成功构建gradle之后,才能正常使用,否则都无法运行。

build.gradle 文件,必须这么配置才可以成功构建gradle,大坑(不过这里要求有代理才行(idea中配置proxy),没有的可以去掉google的maven仓库试试)

// 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 "https://maven.google.com" }
        maven { url "https://jitpack.io" }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        
        // 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 "https://maven.google.com" }
        maven { url "https://jitpack.io" }
        mavenCentral()
    }
}

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

然后刷新了一下gradle,发现里面多出了一些选项

sdk api下载慢可以尝试:

打开http://ping.chinaz.com网站ping一下dl.google.com,找出响应时间最短的内地Ip,复制后打开c:windowssystem32driveretchost文件,在下面添加这个ip dl.google.com

速度就很快了

我用的mi max2,需要进开发者模式给usb调试、usb安装应用、usb修改权限的权限(即打开开关),这样就能在手机上运行app了

原文地址:https://www.cnblogs.com/kinome/p/12288714.html