Flutter - AndroidManifest.xml corrupted after Flutter Upgrade - android

I've just upgraded to Flutter 2 and upgraded an application along with it. I followed all the steps to upgrade the application, but now I can't seem to run the app because my AndroidManifest.xml file seems corrupted.
Here is the xml file (I've also added comments where the errors are appearing).
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finances_management">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name="io.flutter.app.FlutterApplication" <-- Unresolved class 'FlutterApplication'
android:label="finances_management"
android:icon="#mipmap/ic_launcher"> <-- Cannot resolve symbol '#mipmap/ic_launcher'
<activity
android:name=".MainActivity" <-- Unresolved class 'MainActivity'
android:launchMode="singleTop"
android:theme="#style/LaunchTheme" <-- Cannot resolve symbol '#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" <-- Cannot resolve symbol '#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" <-- Cannot resolve symbol '#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>
I've seen elsewhere that people are just completely rebuilding their projects (as in completely generating a new project, stripping business logic from their Flutter 1.x app and copying it across to a Flutter 2.x app). Does anyone know what's happened to my XML file?

The best solution is to downgrade the Flutter . after that update AndroidManifest file

Related

Flutter-Please ensure that the android manifest is a valid XML document and try again

Here I am getting an error while run flutter project.
*** Error parsing LocalFile: 'D:\DEVELOPMENT\Paklayer\park_app\android\app\src\main\AndroidManifest.xml' Please
ensure that the android manifest is a valid XML document and try again. ***
Here is my Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.park_app">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<android:usesCleartextTraffic="true">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="park_app"
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> ```
Add this line inside application tag : <android:usesCleartextTraffic="true">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.park_app">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="park_app"
android:icon="#mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<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>
<!-- Dont 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>
For more info : https://developer.android.com/guide/topics/manifest/application-element

Flutter Android Launch Image does not change / display

Flutter 2.10.3
According to doc and this article. launch_image should work fine.
But it is not displayed. When the application is launched, the application icon is displayed, instead of my custom launch_image
As you can see on screenshot below, launch_image is displayed in Android studio.
Background color works fine.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.untitled">
<application
android:label="untitled"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher"
>
<activity
android:name=".MainActivity"
android:exported="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>
Also, pls do not suggest packages like flutter_native_splash. I need to know, how make it works without packages

Flutter: You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter,

Hey I am working with Flutter, My AndroidManifest.xml looks like this. Not able to get merged manifest in android studio. Can you help me in finding out where am I missing exported=" true", Playstore is not allowing me to update the app?
I tried to update all the dependencies in pubspec.yaml but nothing helped. Checking each library for the manifest file is time-consuming. How can I detect which library manifest file needs to be changed?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.grow90.whatsub">
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<application
android:label="SubSpace"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value=""/>
<activity
android:name=".MainActivity"
exported="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"
/>
<!-- 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="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_onesignal_default" />
<!-- -->
<!-- <meta-data-->
<!-- android:name="com.onesignal.messaging.default_notification_icon"-->
<!-- android:resource="#mipmap/ic_stat_onesignal_default" />-->
<!-- <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>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.settings.APPLICATION_DETAILS_SETTINGS"></uses-permission>
</manifest>
If you are targeting android 12 or 12+ you must specify "android:exported" property to specify whether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not. When the value is "false"
Default value for this attribute is set to false.
So, if you have any activity, alias, service or broadcast receiver with intent-filter registered in your android manifest file then you must specify the "android:exported" attribute to continue.
I updated exported="true" for <activity tag
But issue not resolved.
In my case I was using firebase_messaging & flutter_local_notifications package. I tried to upgrade it but still facing issue.
Temporarily I commented both package, clean/build app and uploaded to Play Store. It got accepted without any issue.
Planned notification and messaging in next version.
Look for packages what makes issue then act accordingly instead of random search.
Thanks!
Dee

Flutter project AndroidManifest.xml file shows compilation errors but app run on android

I started working on a flutter project and everything is working fine. My app compiles and runs on android. However, I opened up this file and noticed that there were a lot of compilation errors. I want to know why this is and how I can fix it. I have included the file and errors listed below. I am working in android studio.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_course">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_course"
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>
IDE error messages
Error:(9, 26) Unresolved package 'flutter'
Error:(9, 34) Unresolved package 'app'
Error:(9, 38) Unresolved class 'FlutterApplication'
Error:(11, 23) Cannot resolve symbol '#mipmap/ic_launcher'
Error:(17, 28) Unresolved class 'MainActivity'
Error:(19, 28) Cannot resolve symbol '#style/LaunchTheme'
Error:(29, 33) Cannot resolve symbol '#style/NormalTheme'
Error:(38, 33) Cannot resolve symbol '#drawable/launch_background'
Ignore the errors. The app should work fine.
I think the errors shows because whatever parses or formats the code can't read XML well. It might go away if you install an XML formatter extension.

Class referenced in the manifest, io.flutter.app.FlutterApplication, was not found in the project or the libraries

need some help I am just new to flutter and don't know what is the error on my AndroidManifest.xml file.In android:name="io.flutter.app.FlutterApplication" ,android:name=".MainActivity". also in Metadata has errors. I don't know if the file is corrupted or not, I have opened other Android flutter projects and it has all the same error on the AndroidManifest.xml file but the APP was running with no errors or anything. now the permissions I add is not working.
`
<uses-permission android:name="android.permission.ACCES_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCES_COARSE_LOCATION"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="clima"
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>
`
That's normal because the Flutter SDK doesn't have code check for Android code. Even if there are warnings thrown from the Android code, you should still be able to run the Flutter app if the Android code doesn't have "real" errors.
What you can do here is to enable code completion for Java/Kotlin on Preferences > Language & Frameworks > Flutter > Experiments. This should remove the warnings thrown on the Android project even if the code is correct.
... or click on Tools > Flutter > Open Android module in Android Studio. This should open the Android build of the Flutter project on Android Studio and help check if the warnings given are correct.

Categories

Resources