为什么 Android Studio 3.2.1 中的新项目模板不使用 AndroidX 库?
Why a new project templates in Android Studio 3.2.1 does not use the AndroidX libraries?
Google 说
"We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well."
source
但是 Android Studio 3.2.1 仍然会创建一个新的项目模板,这些模板受历史 "android.support.*" 库的支持。
为什么?
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.developer.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable: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'
}
直到 Android Studio 3.3 或更高(目前仍然是 Preview/Beta)。
如果您使用它创建一个新项目,您会发现这个 Use AndroidX artifacts
选项。然后一旦创建,你会发现依赖项默认为 androidx.*
Google 说
"We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well." source
但是 Android Studio 3.2.1 仍然会创建一个新的项目模板,这些模板受历史 "android.support.*" 库的支持。
为什么?
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.developer.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable: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'
}
直到 Android Studio 3.3 或更高(目前仍然是 Preview/Beta)。
如果您使用它创建一个新项目,您会发现这个 Use AndroidX artifacts
选项。然后一旦创建,你会发现依赖项默认为 androidx.*