问题描述
我正在遵循教程(9.2),它要求添加一个设置活动",当我尝试选择该活动时,它显示为灰色,并表示需要androidx支持".我在本教程中找不到对androidx支持的引用,并尝试使用Google搜索来解决该问题,但无济于事.我什至从主文件中加载了完成的项目,以将其代码与我的代码进行比较,但我找不到对androidx的引用.我正在使用android studio 3.4.1
I am following the tutorial (9.2), it asks to add a 'settings activity', when i try to select it, it is greyed out and says that it 'requires androidx support'. I can find no reference to androidx support in the tutorial and have tried googling the problem to no avail. I have even loaded the completed project from the master files to compare their code with mine, i can find no reference to androidx. I am using android studio 3.4.1
推荐答案
如前所述,它需要androidx支持.您需要在项目中启用AndroidX.将这两行添加到您的gradle.properties
文件中:
As it says, it requires androidx support. You need to enable AndroidX in your project. Add these two lines to your gradle.properties
file:
android.useAndroidX=true
android.enableJetifier=true
将这两个gradle插件标志设置为true表示Android Plugin将使用适当的AndroidX库而不是支持Library&将重写其二进制文件.另外请注意,由于您需要在该项目中使用AndroidX,因此需要将编译SDK设置为Android 9.0(API级别28)或更高版本.
Setting these two gradle plugin flags to true means that Android Plugin will use appropriate AndroidX library instead of support Library & will rewrite their binaries. Also note that, since you need to use AndroidX in this project, you need to set the compile SDK to Android 9.0 (API level 28) or higher.
要了解更多有关如何将整个项目迁移到AndroidX的信息,请遵循以下链接
For knowing more how to migrate an entire project to AndroidX, please follow this link
这篇关于无法在Android Studio中选择“设置活动"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!