目錄
- 寫在前面
- 建立/打開工程
- gradle下載下傳慢
- gradle版本各種不相容問題(萬惡之源)
- 安裝虛拟機
- 運作
寫在前面
在剛剛接觸Android Studio的小白,開局一個安裝包,能玩四小時,各種坑一個接一個,你以為你解決了bug,運作後恭喜你又解鎖新bug,别問我怎麼知道,說多了都是淚?。

我們從安裝好後開始說起,安裝教程網上有很多,麻煩都是安裝後開始的。
建立/打開工程
建立:
打開:
選擇路徑
無論打開還是建立,總之進到主界面,一通加載後不要慌,點選右下角進度條旁的×:
gradle下載下傳慢
點×的原因是因為它用外網下得超慢,這裡使用阿裡雲鏡像,直接替換圖中代碼:
替換為:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
複制
gradle版本各種不相容問題(萬惡之源)
gradle版本和gradle插件版本的不相容,引出各種各樣的bug,這裡給出小編的使用版本,修改相應代碼即可。
懶人一鍵複制替換:
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
複制
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.bignerdranch.android.geoquiz"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.3.0'
testCompile 'junit:junit:4.12'
}
複制
然後重新開機android studio,等待下方進度條加載,此時會提示你未安裝,點選安裝即可:
再次等待build的進度條:
提示你更新版本可以忽略,至此版本設定就好了。
安裝虛拟機
然而我們還沒有裝置來運作,連接配接手機也可以,這裡介紹安裝虛拟機
然後選擇手機型号,看你喜歡随緣了,當然了,配置低的電腦推薦分辨率低的,不然運作超卡。
點選download,這裡我之前下過了
可以命名虛拟機,預設也行,點選finish
運作
然後你就可以選擇你的虛拟機,再點旁邊的綠色箭頭運作就好了
初次啟動虛拟機會慢一點
至此,第一個app就成功啟動了★,°:.☆( ̄▽ ̄)/$:.°★ 。鬼知道我經曆了什麼。
原創不易,請勿轉載(本不富裕的通路量雪上加霜 )
部落客首頁:https://blog.csdn.net/qq_45034708