AndroidStudio使用笔记

1.模拟器选择Nexus One,运行模拟器才有效果。

3.AS工程中部分文件的作用:

AndroidManifest.xml:App基本信息
java:Java代码,包含工程和新建是默认产生的Test工程源码。
res:资源文件,类似Eclipse。
layout:App布局及界面元素配置。
menu:App菜单配置,雷同Eclips。
dimens.xml:定义css的配置文件。
strings.xml:定义字符串的配置文件。
styles.xml:定义style的配置文件。
ic_launcher-web.png:App图标
build.gradle:Module的Gradle构建脚本

2.AS中的gradle是一种系统构建工具,其部分文件内容解释:

(1) Project: build.gradle

buildscript {        //设置脚本的运行环境
    repositories {  //支持java依赖库管理(maven/ivy等),用于项目的依赖
        google()
        jcenter()   //推荐使用这个仓库
        
    }
    //依赖包的定义。支持maven/ivy、远程、本地库、单文件。前面定义的jcenter库,使用jcenter的依赖只需要按照
    //类似于com.android.tools.build:gradle:3.3.1,gradle就会自动的往远程库下载相应的依赖。
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

//多项目的集中配置,多数构建工具,对于子项目的配置,都是基于继承的方式。Gradle除了提供继承方式设置子项目,还提供这种配置
allprojects {
    repositories {
        google()
        jcenter()
        
    }
}

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

(2) Module: build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28                        //编译需要SDK版本
    defaultConfig {
        applicationId "com.example.mm.first"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {                    //编译项
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {    //依赖支持
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

(3) settings.gradle

include ':app' //module  include ':my_lib' //module(build as lib)

参考:

Android Studio教程从入门到精通:http://www.cnblogs.com/laughingQing/p/5848425.html

猜你喜欢

转载自www.cnblogs.com/hellokitty2/p/10776054.html