首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android :无法访问未找到的MenuHost类文件androidx.core.view.MenuHost

Android :无法访问未找到的MenuHost类文件androidx.core.view.MenuHost
EN

Stack Overflow用户
提问于 2021-11-26 13:47:24
回答 4查看 4.4K关注 0票数 4

我在构建我的项目时出错了。这是我的错误信息:无法访问MenuHost类文件的androidx.core.view.MenuHost未找到。

我没有找到任何解决这个问题的办法。如果你能帮我,我会很高兴的。对于一个空活动,我得到了这个错误:

代码语言:javascript
运行
复制
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class CallActivity extends AppCompatActivity {
    /* Access modifiers changed, original: protected */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( R.layout.activity_call);
    }
}

这是我的build.gradle (应用程序):

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"


    defaultConfig {
        applicationId "com.example.ghostcontact"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


    }


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    configurations.all {

        resolutionStrategy {
            force 'androidx.core:core:1.6.0'
            force 'androidx.core:core-ktx:1.6.0'
        }
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'


    implementation 'com.android.support.constraint:constraint-layout:2.0.4'
    implementation 'com.google.firebase:firebase-database:20.0.2'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-storage:20.0.0'

    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'

    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.hbb20:ccp:2.3.1'

    implementation 'com.google.android.gms:play-services-base:17.6.0'
    implementation 'com.google.firebase:firebase-core:20.0.0'
    implementation 'com.google.firebase:firebase-crashlytics:18.2.4'
    implementation 'com.google.firebase:firebase-analytics:20.0.0'


    implementation 'com.squareup.picasso:picasso:2.71828'

    implementation 'commons-validator:commons-validator:1.6'

    implementation 'com.airbnb.android:lottie:3.4.0'

    //OTP PIN View Design
    implementation 'com.chaos.view:pinview:1.4.3'

    implementation 'androidx.preference:preference:1.1.1'

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.core:core:1.6.0'


    implementation 'com.google.android.material:material:1.4.0-alpha02'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'androidx.activity:activity:1.4.0'
    implementation 'androidx.activity:activity-compose:1.4.0'
    implementation 'androidx.activity:activity-ktx:1.4.0'


}

和我的build.gradle (项目)

代码语言:javascript
运行
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
        maven{url 'https://maven.fabric.io/public'}
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.4'
        classpath  'com.google.gms:google-services:4.3.10'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven{url 'https://jitpack.io'}
        maven{url 'https://dl.bintray.com/tapsellorg/maven'}
        maven{url 'https://maven.google.com/'}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
EN

回答 4

Stack Overflow用户

发布于 2021-12-14 10:19:31

也有同样的问题。通过删除以下行修正了这个问题:

代码语言:javascript
运行
复制
     configurations.all {
        resolutionStrategy { force 'androidx.core:core:1.6.0' }
     }

defaultConfig of build.gradle(:app)

我也不知道错误的来源/原因。

票数 5
EN

Stack Overflow用户

发布于 2022-07-22 17:42:21

MenuHostandroidx.core:core:1.7.0及以上版本中添加。

https://developer.android.com/jetpack/androidx/releases/core#1.7.0-alpha02

只需升级您的依赖项。

票数 2
EN

Stack Overflow用户

发布于 2022-04-28 10:20:43

只需添加依赖项:

代码语言:javascript
运行
复制
implementation 'androidx.core:core:{latest version}' // 1.7.0 or above
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70125444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档