如何使 AndroidX 成为新 Android 项目的默认库?
How can I make AndroidX the default library for new Android projects?
Google 现在建议使用 AndroidX 库而不是旧的支持库 (read here),但每次我在 [= 中开始一个新的 Android 项目时23=] studio,它默认支持库依赖。由于 AndroidX 是推荐的,我猜必须有一些方法可以默认为 AndroidX?
现在我需要为每个新项目手动配置gradle.properties文件,如下
If you want to use AndroidX in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher and set both of the following Android Gradle plugin flags to true in your gradle.properties file.
android.useAndroidX: When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.
android.enableJetifier: When set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. The flag is false by default if it is not specified.
有没有办法让 Android Studio 默认只使用 AndroidX?
AndroidX 默认启用。事实上,在最新版本的 Android Studio 中,您甚至没有取消选择 AndroidX 依赖项的选项。看这里:
已选择 androidx.*
个工件。如果您的 Android Studio 不支持此功能,请尝试更新或重新安装。确保不要从 IDE 中导入旧的首选项。它会刷新你的 IDE.
当您在最新版本的 android studio 中创建任何新项目时,它将默认使用 androidX 库打开。
Google 现在建议使用 AndroidX 库而不是旧的支持库 (read here),但每次我在 [= 中开始一个新的 Android 项目时23=] studio,它默认支持库依赖。由于 AndroidX 是推荐的,我猜必须有一些方法可以默认为 AndroidX?
现在我需要为每个新项目手动配置gradle.properties文件,如下
If you want to use AndroidX in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher and set both of the following Android Gradle plugin flags to true in your gradle.properties file.
android.useAndroidX: When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.
android.enableJetifier: When set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. The flag is false by default if it is not specified.
有没有办法让 Android Studio 默认只使用 AndroidX?
AndroidX 默认启用。事实上,在最新版本的 Android Studio 中,您甚至没有取消选择 AndroidX 依赖项的选项。看这里:
已选择 androidx.*
个工件。如果您的 Android Studio 不支持此功能,请尝试更新或重新安装。确保不要从 IDE 中导入旧的首选项。它会刷新你的 IDE.
当您在最新版本的 android studio 中创建任何新项目时,它将默认使用 androidX 库打开。