我的 list 文件中有问题,因此我无法运行我的应用程序。它说 :
不能将'com.diridou.mescoiffeurs.MainActivity'分配给'android.app.Activity'...(Ctrl + F1)
检查信息:验证Android XML文件中的资源引用
MainActivity扩展了AppCompatActivity,但我无法解析AppcompactActivity
我也没有任何问题。
我补充说:
1度
android.enableJetifier=true
android.useAndroidX=true
在我的graddle.properties中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.diridou.mescoiffeurs">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
public class MainActivity extends AppCompatActivity {
}
我的毕业文件看起来像:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.diridou.mescoiffeurs"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
/*Dependencies de base */
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
/*Firebase*/
implementation 'com.google.firebase:firebase-firestore:20.1.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}
最佳答案
在gradle.properties中,已将标志设置为使用AndroidX,但是,您不导入任何AndroidX资源。相反,您正在使用支持依赖项。要解决此问题,请在build.gradle
中,检查此link是否声明了任何依赖项,并将其替换为相应的androidx
依赖项。
关于android-studio - 如何解决: 'com.xxx.xxxx.MainActivity'不能少分配给 'android.app.Activity',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56936498/