简体   繁体   中英

How can I make AndroidX the default library for new Android projects?

Google now recommends using the AndroidX libraries over the older support libraries ( read here ), yet each time I start a new Android project in Android studio, it defaults to the support libraries dependencies. Since AndroidX is what is recommended, I'm guessing there must be some way to default to AndroidX?

Right now I need to manually configure the gradle.properties file for each new project, as below

From the AndroidX Documentation :

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.

Is there a way to make Android Studio use only AndroidX by default?

AndroidX is enabled by default. In fact, in the latest version of Android Studio, you don't even have the option to deselect the AndroidX dependencies. See here:

样例项目

The androidx.* artifacts are already selected. If your Android Studio doesn't support this, try updating it or installing it again. Make sure to not import the older preferences from your IDE. It will refresh your IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM