Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何修复“错误:包android.support.v7.widget不存在”问题?_Java_Android_Android Studio_Gradle - Fatal编程技术网

Java 如何修复“错误:包android.support.v7.widget不存在”问题?

Java 如何修复“错误:包android.support.v7.widget不存在”问题?,java,android,android-studio,gradle,Java,Android,Android Studio,Gradle,我想在我的应用程序中添加一个操作栏。出现了一个问题 错误:包android.support.v7.widget不存在 无论我怎么努力,都无法解决那个问题。互联网上的任何解决方案对我都不起作用。我不知道为什么会发生这种情况,我真的厌倦了。我是初学者,这个问题让我发疯。我试着改变 android.useAndroidX=true->to false 及 gradle.properties上的android.enableJetifier=true->false 是的,它的工作!但出现了另一个问题: j

我想在我的应用程序中添加一个操作栏。出现了一个问题

错误:包android.support.v7.widget不存在

无论我怎么努力,都无法解决那个问题。互联网上的任何解决方案对我都不起作用。我不知道为什么会发生这种情况,我真的厌倦了。我是初学者,这个问题让我发疯。我试着改变

android.useAndroidX=true->to false

gradle.properties上的android.enableJetifier=true->false

是的,它的工作!但出现了另一个问题:

java.lang.RuntimeException: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
这是我的身材。格雷德尔:

    compileSdkVersion 29
    buildToolsVersion '29.0.1'
    minSdkVersion 21
    targetSdkVersion 29


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
    implementation 'com.google.android.material:material:1.1.0-alpha07'
    testİmplementation 'junit:junit:4.13-beta-3'
    androidTestİmplementation 'androidx.test:runner:1.3.0-alpha01'
    androidTestİmplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0'

}
可能是执行方法上的问题,我不知道。可能是我在SDK版本上有问题。我已尝试迁移到AndroidX,但未成功。

请尝试以下操作:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
请试试这个:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
欢迎来到stackoverflow

您在一个项目中同时拥有支持库和androidx库…这是您的问题

将支持库更改为首选的AndroidX库

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
    implementation 'com.google.android.material:material:1.1.0-alpha07'
    testİmplementation 'junit:junit:4.13-beta-3'
    androidTestİmplementation 'androidx.test:runner:1.3.0-alpha01'
    androidTestİmplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

}
或者,您也可以迁移到AndroidX,这样就可以在Android Studio中完成

只需进入重构>迁移到AndroidX>迁移

添加操作栏

<androidx.appcompat.widget.Toolbar
   android:id="@+id/toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="@color/yourColor"/>
我希望这有帮助……

欢迎来到stackoverflow

您在一个项目中同时拥有支持库和androidx库…这是您的问题

将支持库更改为首选的AndroidX库

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
    implementation 'com.google.android.material:material:1.1.0-alpha07'
    testİmplementation 'junit:junit:4.13-beta-3'
    androidTestİmplementation 'androidx.test:runner:1.3.0-alpha01'
    androidTestİmplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

}
或者,您也可以迁移到AndroidX,这样就可以在Android Studio中完成

只需进入重构>迁移到AndroidX>迁移

添加操作栏

<androidx.appcompat.widget.Toolbar
   android:id="@+id/toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="@color/yourColor"/>
我希望这会有帮助……

尝试更换

android.support.v7.widget

试着替换

android.support.v7.widget


您使用androidx的项目以及支持libso迁移到AndroidXPossible的副本谢谢,我不知道。您使用androidx的项目以及支持libso迁移到AndroidXPossible的副本谢谢,我不知道。谢谢您的回答。我已经试过了,但问题仍然存在。谢谢你的回答。我试过了,但问题仍然存在。是的,谢谢你的帮助。但如果我问,为什么我们不能同时使用支持库和AndroidX呢。因为我看了一个教程,他们可以导入android.support.v7.widget.Toolbar,所以我建议你使用支持库,而不是androidx'android.support.v7.widget.Toolbar'和'androidx.appcompat.widget.Toolbar'做同样的事情……教你的教程有点旧了……但是你还有什么问题吗?戴夫,我真的很担心很高兴你的帮助,真的谢谢!最后一个问题是,如何仅使用v7.widget?我只是想知道。有一种方法你可以在你的项目中使用android.support.v7.widget.Toolbar。但是你以后可能会遇到问题。将com.google.android.material:material:1.1.0-alpha07替换为com.android.support:design:28.0.0然后转到您的AndroidManifest.xml并添加工具:Replace=android:appComponentFactory android:appComponentFactory=whateverString就在您的应用程序标记下方…它应该可以工作。谢谢您的帮助。但如果我问,为什么我们不能同时使用支持库和AndroidX呢。因为我看了一个教程,他们可以导入android.support.v7.widget.Toolbar,所以我建议你使用支持库,而不是androidx'android.support.v7.widget.Toolbar'和'androidx.appcompat.widget.Toolbar'做同样的事情……教你的教程有点旧了……但是你还有什么问题吗?戴夫,我真的很担心很高兴你的帮助,真的谢谢!最后一个问题是,如何仅使用v7.widget?我只是想知道。有一种方法你可以在你的项目中使用android.support.v7.widget.Toolbar。但是你以后可能会遇到问题。将com.google.android.material:material:1.1.0-alpha07替换为com.android.support:design:28.0.0然后转到您的AndroidManifest.xml并添加工具:Replace=android:appComponentFactory android:appComponentFactory=whateverString就在您的应用程序标记下方…它应该可以工作