skip to Main Content

I came to realize that there are errors in my main/AndroidManifest.xml file. Most of them report: "Atribute android:** not allowed here" (** = icon, launchMode, theme, configChanges, hardwareAccelerated, usesCleartextTraffic and windowSoftInputMode). There is also an error: "Unresolved class ‘.MainActivity’ (see attached screenshot).

This does not hinder building the app, and publishing it, but some functions are not working.

I tried to create a new and clean flutter project (counting taps), but got the same errors. I tried to create a new flutter project on a different computer and even on different os (both Windows and Mac) but the problems are still there. And I updated to the newest Android Studio (Arctic Fox 2020.3.1).

Pub get finished with exit code 0.
Pub upgrade finished with exit code 0.
Pub outdated finished with exit code 0.
Flutter doctor -v reports:

[✓] Flutter (Channel master, 2.5.0-7.0.pre.105, on Mac OS X 10.15.7 19H1323 darwin-x64, locale nb-NO)
• Flutter version 2.5.0-7.0.pre.105 at /Users/christianottoruge/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a2e33dec7c (8 hours ago), 2021-08-16 22:51:16 -0700
• Engine revision 7dc8eba6ae
• Dart version 2.15.0 (build 2.15.0-15.0.dev)

[✓] Android toolchain – develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/christianottoruge/Library/Android/sdk
• Platform android-30, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.

[✓] Xcode – develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.10.1

[✓] Chrome – develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131

• No issues found!

I have closed and reopened the AndoidManifest file.
I have tried File -> Invalidate caches/Restart.
I have set File -> Project Structure -> Project Project SDK to "Android API 29 platform".
I have built, cleaned and rebuilt the project.

My AndroidManifest file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test_test_test.test_test_test">

   <application
        android:label="test_test_test"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            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"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <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>

The error messages look like this:

Errors – screenshot

There is no MainActivity.xml file, but there is a MainActivity.kt file placed in app/src/main/kotlin/test_test_test/test_test_test/.

The code is:

package com.test_test_test.test_test_test

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

Anyone who can help me out with this issue?

Kind regards, Christian

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to @joachimwedin for putting me on the right track.

    There was a problem inside the build.gradle file and in the File -> Project settings -> Modules -> Dependecies "Module SDK" that was not properly set. I also changed "GradleException()" to "FileNotFoundException()" in build.gradle. See: https://github.com/flutter/flutter/issues/29608#issuecomment-548649907 for details. After File -> Invalidate Caches / Restart, this removed all my androidManifest errors for a while - but then they returned.

    What solved the issue for me was to add the package name to the location for the ".MainActivity". The result is: "'package'.MainActivity". The error is gone now and issue solved.


  2. If you haven’t tried it already, this might help: close the manifest and then in Android Studio do File -> Sync Project with Gradle Files.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search