为了不与Java开发混用,所以不使用IDEA开发安卓应用而选择Android Studio。

官网下载安装 Android Studio(https://developer.android.google.cn/studio/)

 

 

启动时会提示 Unable to access Android SDK add-on list,点 cancel,然后就会弹出Android SDK和其他组件的下载窗口,这时下载即可。

dl.google.com已经不被墙了,现在直连速度就很快。如果速度很慢或者连不上,请修改DNS

 Android Studio安装及其使用

 

 

 

 

Android Studio下载的SDK默认会在 C:\Users\当前用户\AppData\Local\Android\Sdk

(AppData目录是带隐藏属性的,请打开显示隐藏文件(夹))

Android Studio安装及其使用

 

 在 Default Project Structure... 里可以配置/下载Android SDK和NDK

 

 如何确认网络连接有效呢?点一下Plugins,如果Marketplace里能显示在线插件,则代理有效。

 

关于Android Studio默认的Gradle

Android Studio安装及其使用

 

 可以看到默认用得是wrapper{善用搜索引擎可找到路径在 C:\Users\用户名\.gradle\wrapper\dists\gradle-5.1.1-all\97z1ksx6lirer3kbvdnt7jtjg(这个目录名随机)\gradle-5.1.1  }

但是没有配置环境路径,也就是说这个Gradle只有Android Studio在用

根据 "C:\Users\用户名\.gradle\wrapper\dists\gradle-5.1.1-all\97z1ksx6lirer3kbvdnt7jtjg\gradle-5.1.1\init.d\readme.txt" 的指示,等等,这一步还没测试成功,请直接看下面的"项目Gradle配置"

我们还可以自己编写 init.gradle 文件并放在此目录下用于自动化配置

 

项目Gradle配置

如果只想对项目生效,只需修改项目下的build.gradle文件

buildscript {
repositories {
里google()和jcenter()的上面 添加如下两行即可:
// 添加阿里云 maven 地址
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }

 

 

效果:

Android Studio安装及其使用

 完整简单项目下的build.gradle

Android Studio安装及其使用
 1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 2 
 3 buildscript {
 4     repositories {
 5 
 6         // 添加阿里云 maven 地址
 7         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
 8         maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
 9 
10         // jcenter()
11         google()
12     }
13     dependencies {
14         classpath 'com.android.tools.build:gradle:3.4.2'
15         // NOTE: Do not place your application dependencies here; they belong
16         // in the individual module build.gradle files这里的3.4.2是和gradle 5.1.1对应的,请勿随便修改
17     }
18 }
19 
20 allprojects {
21     repositories {
22 
23         // 添加阿里云 maven 地址
24         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
25         maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
26 
27         // jcenter()
28         google()
29     }
30 }
31 
32 task clean(type: Delete) {
33     delete rootProject.buildDir
34 }
View Code

相关文章:

  • 2022-02-09
  • 2021-11-06
  • 2022-12-23
  • 2021-11-13
  • 2021-10-15
  • 2022-12-23
  • 2021-10-28
  • 2021-07-11
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-08-12
  • 2021-07-12
  • 2021-11-21
  • 2022-03-09
相关资源
相似解决方案