android build.gradle

现在 android 开发 SDK一般选择用最新的SDK版本,这是Google官方强烈建议的。
app能运行的Android版本不是由SDK决定的,是由每一个项目的minSDK决定的。

SDK都是向下兼容的。SDK在不断改进中,新的SDK会提供更强大开发工具,而且用4.0的SDK编译的2.1的apk的执行效率会比用2.1的SDK编译的更高。
至于每个app应该用什么 minSDK ,应该根据应用具体的API来,如果app没有用到1.6以上SDK新提供的API,那么用1.6会在提供相同体验下反而会比2.1兼容更多机型. 

 

 

build.gradle(Project:MES)

 这个文件中配置内容将会应用到所有modules中

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
     //*******gradle插件的版本号,升级android studio时,可能需要更改这个版本号 classpath
'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }

 

C盘路径

C:\Users\admin\.gradle(c盘自动生成)

 

查看和选择当前项目关联的Gradle

 

 

D盘下的路径(android 实际安装的位置)

D:\Program Files\Android\Android Studio\gradle

 

  build.gradle(Module:app)   'app'是我建的工程名

apply plugin: 'com.android.application'

android {
  //编译的SDK版本
    compileSdkVersion 26  //27
  //android构建工具的版本,在SDK Manager中安装选择版本,buildToolsVersion的版本需要>=CompileSdkVersion; 
  //高版本的build-tools 可以构建低版本编译的android程序
    buildToolsVersion "26.0.0"//27.0.3
    defaultConfig {
    //应用程序的包名
        applicationId "com.example.admin.mes"
    //支持的最低版本,操作系统会拒绝将应用安装在系统版本低于此标准的设备上
        minSdkVersion 15
    //支持的目标版本,最佳选择为最新的API级别
        targetSdkVersion 26  //27
    //版本号
        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'
    })
    //7:27
  //依赖的基础库25.3.1
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

 C:\Users\admin\AppData\Local\Android\Sdk\extras\android\m2repository\com\android\support

程序里写的

 

 

使用国内

https://maven.aliyun.com/mvn/guide

        maven {
            url 'https://maven.aliyun.com/repository/public/'
        }
        mavenLocal()
        mavenCentral()

 

posted @ 2018-04-13 21:14  富坚老贼  阅读(185)  评论(0编辑  收藏  举报