Home > Software design >  Error in AndroidManifest.xml in Flutter App "Attribute class not Found"
Error in AndroidManifest.xml in Flutter App "Attribute class not Found"

Time:11-22

AndroidManifest.xml showing me 10 errors in the code below. I am unable to understand why it is showing these errors and how can I resolve this. Help me out from these errors.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.buis_talk">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

   <application
   android:requestLegacyExternalStorage="true"
        android:label="buis_talk"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:usesCleartextTraffic="true"
            
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

These are the errors

Errors are:-

  1. android:requestLegacyExternalStorage="true" - "Attribute android:requestLegacyExternalStorage is not allowed here"
  2. android:name="${applicationName}" - "Unresolvedclass:'{applicationName}'"
  3. android:icon="@mipmap/ic_launcher"> - "Attribute android:icon is not allowed here"
  4. android:name=".MainActivity" - "Unresolved class MainActivity"
  5. android:usesCleartextTraffic="true" - "Attribute android:usesCleartextTraffic is not allowed here"
  6. android:launchMode="singleTop" - "Attribute android:launchMode is not allowed here"
  7. android:theme="@style/LaunchTheme" - "Attribute android:theme is not allowed here"
  8. android:configChanges="....." - "Attribute android:configChanges is not allowed here"
  9. android:hardwareAccelerated="true" - "Attribute android:hardwareAccelerated is not allowed here"
  10. android:windowSoftInputMode="adjustResize"> - "Attribute android:windowSoftInputMode is not allowed here"

CodePudding user response:

TLDR

I think if you open the android folder separately in Android Studio, then you should be able to see properly. (Maybe, I'm not sure).

Long answer

Android Studio can't understand the Android content when a Flutter project is opened.

If it's a simple Android project, then it can easily understand the Gradle files and your Java/Kotlin.

What this means for you as a Flutter developer is that, when you are editing native Android or iOS code. You will not get code completion. Android Studio will not be able to tell you about the errors in your code.

The Flutter team is working on this. So that you can have all the cool IntelliJ features for editing Native code EVEN when you have a Flutter project is opened.

Also, I think if you open the android separately, then you should be able to see properly. (Maybe, I'm not sure).

CodePudding user response:

  1. If project is getting failed when you run it then as it is showing in attached image; at the end of line no 29 that a z is added mistakenly.

  2. And project is running fine but you are worried about code being red/wrong; just ignore it as @powerman23rus explained it in detail.

  3. Also if point 1 & 2 is not applicable then you have to post full error logs for us to trace the issue origins.

  • Related