谷歌说
"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或更高版本(目前仍是预览版/测试版)。
如果你用它创建一个新项目,你会发现这个Use AndroidX artifacts
选项。然后创建之后,你会发现依赖项默认是androidx.*
关于android - 为什么 Android Studio 3.2.1 中的新项目模板不使用 AndroidX 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53546434/