我在使用 Android Studio 時遇到了問題。當我嘗試運行任何應(yīng)用程序時,我收到相同的錯誤“未找到默認活動”,并且在我的代碼中tools:context=".MainActivity",MainActivity 以紅色突出顯示,并顯示“未解析的類 MainActivity”。即使我創(chuàng)建了一個全新的“空活動”,它也會發(fā)生。到目前為止,我已經(jīng)嘗試過:刷新IDE緩存檢查 Android 清單和 MainActivity 中的包名稱選擇默認活動應(yīng)用內(nèi)配置確保 src 是源目錄我還注意到,在我的“最高級”應(yīng)用程序中,它build.gradle看起來像這樣:安卓清單:<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.justjava"> <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"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
未解決的類 MainActivity
HUH函數(shù)
2022-06-04 15:08:28