Android Studio安裝及其使用


為了不與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下載的SDK默認會在 C:\Users\當前用戶\AppData\Local\Android\Sdk

(AppData目錄是帶隱藏屬性的,請打開顯示隱藏文件(夾))

 

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

 

 如何確認網絡連接有效呢?點一下Plugins,如果Marketplace里能顯示在線插件,則代理有效。

 

關於Android Studio默認的Gradle

 

 可以看到默認用得是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' }

 

 

效果:

 完整簡單項目下的build.gradle

 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

 

 

附上:

Gradle、Maven使用阿里雲鏡像-阿里官方文檔  https://help.aliyun.com/document_detail/102512.html

 

 

 

如果出現

ERROR: Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: C:\Users\xx\AppData\Local\Android\Sdk

,點 Install missing SDK package(s)即可

 

 

SDK對應的版本配置可在Settings里搜索SDK

 

 

相對布局使用方法:

要關閉這個 自動吸附父控件

才能調整拖放的控件距離

 

 然后長按這些,可以設置相對哪個控件放置及其相對距離

 

 

 

 

This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you

原因是沒有設置約束,約束布局是結合了相對布局並改進的新特性,所以如上圖設置相對的方法也可用於約束布局

或者點一下按鈕:https://blog.csdn.net/BSSYNHDJZMH/article/details/79728625#解決方案


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM