无法将android.support.v7.widget.Toolbar与android.useAndroidX = true一起使用 [英] Can't use android.support.v7.widget.Toolbar with android.useAndroidX=true
问题描述
在app/build.gradle中:
in app/build.gradle:
implementation 'com.android.support:appcompat-v7:28.0.0'
我在活动中使用
import android.support.v7.widget.Toolbar
好.是工作发现者.
但是当我迁移到androidx
时,我会添加以下内容:
But when I migrate to androidx
I add this:
android.useAndroidX=true
android.enableJetifier=true
结果是我的活动现在没有编译错误:
As result now my activity not compile with error:
import android.support.v7.widget.Toolbar;
Cannot resolve symbol 'v7'
是否可以将android.support.v7.widget.Toolbar
与anrdoidx.*
软件包一起使用?
Is it possible to use android.support.v7.widget.Toolbar
together with anrdoidx.*
package?
推荐答案
由于您正在将项目迁移到 androidx
Since you are migrating your project to androidx
-
使用Android Studio 3.2及更高版本,您可以迁移现有的 通过从中选择 Refactor>迁移到AndroidX ,将项目迁移到AndroidX 菜单栏.
With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
删除具有 v7 支持的导入,并在整个项目中导入 androidx 依赖项.
Remove imports having v7 support and import androidx dependencies all over in your project.
回答第二个查询:您无法在同一项目中同时使用v7支持库和androidx,因为androidx完全替代了Android Jetpack中提供的支持库.
Answering your second query : you cannot use both v7 support library and androidx in same project as androidx is full replacement of the Support Library provided in Android Jetpack.
还更新您的项目以使用支持库的最终版本:版本28.0.0 (强烈建议).
Also update your project to use the final version of the support library: version 28.0.0 (highly recommended).
有关androidx迁移的更多详细信息,请访问此链接.
For further details about androidx migration visit this link.
希望它会有所帮助:)
这篇关于无法将android.support.v7.widget.Toolbar与android.useAndroidX = true一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!