Android Studio中AndroidManifest.xml未解析包/类错误求助
Hey there, let's work through this frustrating error together. I've dealt with similar unresolved class issues in Android Studio before, so let's break down the most likely fixes step by step:
1. Verify the LoginController Class Details First
- Double-check the package declaration in your
LoginController.java(or.kt) file. It must exactly match what's in the Manifest:package psychosomatik.mimikapp; // This line must be present and correct - Ensure the class name matches exactly (case-sensitive!). Android Studio treats
LoginControllerandlogincontrolleras different classes, even if your Windows file system doesn't. - Confirm the file is located in the correct directory:
C:\Android Stuff\MimikApp\app\src\main\java\psychosomatik\mimikapp\LoginController.java(thejavafolder is crucial—if it's inresor another folder, it won't be compiled as a Java class).
2. Check Your Build.Gradle Configuration
Since you mentioned only one build.gradle file, I assume it's the module-level one (in the app directory):
- Verify the
applicationIdmatches your Manifest's package name:android { defaultConfig { applicationId "psychosomatik.mimikapp" // Must match <manifest package="..." /> } } - Ensure your source sets are correctly configured (this is usually default, but worth checking):
android { sourceSets { main { java.srcDirs = ['src/main/java'] } } }
3. Perform a Deep Clean & Cache Reset
Sometimes standard rebuilds aren't enough—try these more thorough steps:
- Go to
File > Invalidate Caches... > Invalidate and Restart. This wipes Android Studio's cached indexes, which often fixes false "unresolved" errors. - Manually delete the
buildfolder in yourappdirectory (C:\Android Stuff\MimikApp\app\build), then rebuild the project. - Click the "Sync Project with Gradle Files" button (the elephant icon in the toolbar) to ensure all Gradle configurations are fully synced.
4. Critical Check: Is LoginController an Application Subclass?
You've set android:name="psychosomatik.mimikapp.LoginController" in the <application> tag—this requires that LoginController extends the Android Application class. If it's an Activity, Fragment, or regular utility class, this is invalid and will cause the error.
Fix if LoginController is NOT an Application class:
Remove the android:name attribute from the <application> tag (the system will use the default Application class):
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <!-- Your activities here --> </application>
Fix if LoginController IS meant to be the Application class:
Ensure your class extends Application:
package psychosomatik.mimikapp; import android.app.Application; public class LoginController extends Application { // Your custom application logic here }
Start with step 4—it's a common oversight that's easy to miss, then work through the other steps if needed.
内容的提问来源于stack exchange,提问作者Brixzz

