Android Studio首次运行指南

时间:2022-07-25
本文章向大家介绍Android Studio首次运行指南,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

目录

  • 写在前面
  • 新建/打开工程
  • 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