When I run a Flutter project, it says "build failed due to use of deprecated android v1 embedding" [duplicate] - flutter

I have an error in the flutter project that I cloned from GitHub. I tried this method but it didn't work
<application
android:name="io.flutter.app.FlutterApplication"
To:
<application
android:name="${applicationName}"
error:
AndroidManifest.xml:

It may sound like a fake solution, but indeed, the easiest way to resolve this is:
Delete the android folder.
Run flutter create .
The command will recreate the android folder with the already migrated code. Also, the command will create folders for the other stable platforms (e.g. web, windows), so you could ignore those and just delete them or trigger the flutter create command by defining android platform - flutter create --platforms=android ..

The best solution I found when I got this problem with my older Flutter projects is to start fresh.
Rename the old project folder.
Create a new Flutter project using the latest Android Studio or command line.
Copy/paste the old code from your backup folder.
Be careful not to replace any of the control files: pubspec.yaml, Android folder, iOS folder, Gradle, etc.
You will find the problem solved.

Add the following code in android manifest after activity
<meta-data
android:name="flutterEmbedding"
android:value="2" />
In project build.gradle add the following code in buildscript
ext.kotlin_version = '1.6.10'
And change gradle version in gradle-wrapper.properties
My manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.stackoverflowexample">
<application
android:label="stackoverflowexample"
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>

Add below lines in AndroidManifest.xml file
<meta-data
android:name="flutterEmbedding"
android:value="2" />
For more details : https://docs.flutter.dev/release/breaking-changes/android-v1-embedding-create-deprecation

Related

related with flutter gradle version

I changed some codes in gradle files for using external project.
but now facing with problems below, how can I work arrange these?
/AndroidManifest.xml Error:
android:exported needs to be explicitly specified for element <activity#com.example.awesome_flutter_layouts.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
Manifest merger failed : android:exported needs to be explicitly specified for element <activity#com.example.awesome_flutter_layouts.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
<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>
try to add android:exported="true"

How do I fix the Google play app bundle issue

How do I fix the Google play app bundle issue which stats the the APK or Andriod App Bundle which has an activity, activity alias, service or broadcast reciever with intent filter, but without android: exported property set this file can't be installed on Android 12 or higher.
In manifest. Xml add android exported true like
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
</activity>

Flutter build failed due to use of deprecated Android v1 embedding

I have an error in the flutter project that I cloned from GitHub. I tried this method but it didn't work
<application
android:name="io.flutter.app.FlutterApplication"
To:
<application
android:name="${applicationName}"
error:
AndroidManifest.xml:
It may sound like a fake solution, but indeed, the easiest way to resolve this is:
Delete the android folder.
Run flutter create .
The command will recreate the android folder with the already migrated code. Also, the command will create folders for the other stable platforms (e.g. web, windows), so you could ignore those and just delete them or trigger the flutter create command by defining android platform - flutter create --platforms=android ..
The best solution I found when I got this problem with my older Flutter projects is to start fresh.
Rename the old project folder.
Create a new Flutter project using the latest Android Studio or command line.
Copy/paste the old code from your backup folder.
Be careful not to replace any of the control files: pubspec.yaml, Android folder, iOS folder, Gradle, etc.
You will find the problem solved.
Add the following code in android manifest after activity
<meta-data
android:name="flutterEmbedding"
android:value="2" />
In project build.gradle add the following code in buildscript
ext.kotlin_version = '1.6.10'
And change gradle version in gradle-wrapper.properties
My manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.stackoverflowexample">
<application
android:label="stackoverflowexample"
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>
Add below lines in AndroidManifest.xml file
<meta-data
android:name="flutterEmbedding"
android:value="2" />
For more details : https://docs.flutter.dev/release/breaking-changes/android-v1-embedding-create-deprecation

Flutter Cleartext HTTP traffic not permitted

I have gone through the usual answers. I have edited the info.plist on iOS and added the network_config.xml in Android. This works perfectly when running the project from XCode, but when trying to run the debug from Android Studio, I get the
Cleartext HTTP traffic to 192.168.1.54 not permitted
Seems like Flutter is ignoring my iOS and Android configurations regarding this matter, but only when running it directly from Android Studio.
Please add below code in your manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
You can read details here https://medium.com/#imstudio/android-8-cleartext-http-traffic-not-permitted-73c1c9e3b803

unable to deploy Android APK on a blackberry device

I have been trying to figure this out for a couple of days now,
I created some apps, I followed the steps to get a signed APK (https://www.udacity.com/wiki/ud853/course_resources/creating-a-signed-apk) .
The APK installs fine on android devices, but when I try to deploy on BB device, I get a "unable to install" message. An APK (downloaded from google play to my PC, then saved to the BB device) installs fine on the BB device, but non of my apps can be installed.
I think I am missing something I should do before or after creating the signed APK. Is there a way to diagnose or find the reason the installation is failing??
Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.asamater.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Solved:
minimum supported API must be 18 or under.