android - 为什么 Android Studio 3.2.1 中的新项目模板不使用 AndroidX 库?

标签 android android-studio androidx

谷歌说

"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.*

enter image description here

关于android - 为什么 Android Studio 3.2.1 中的新项目模板不使用 AndroidX 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53546434/

相关文章:

android - 相机应用程序在 android ffmpeg 应用程序上失败

android-studio - 安卓工作室 : always getting Failure [INSTALL_FAILED_DEXOPT]

android.support.v4.app.INotificationSideChannel$Stub$Proxy

androidX jetifier - 有没有办法忽略 jetifying .JAR?

java - 如何获取设备的总存储大小?

java - 如何在 Android Studio 上以编程方式更改小部件 ID

android - 如何使用新的 androidx.lifecycle :*:2. 2.0-alpha01 获取 lifecycle.coroutineScope

android - 从 phonegap 重启设备

java - 由于包不存在,Android Studio 无法生成 Javadoc

android - 使用 androidx 获取 fragment 内的 actionBar