Reputation: 6980
I'm working on a Flutter project for Android and encountered an error related to the AndroidManifest.xml file. When trying to run my project, I receive the following error message:
package identifier or launch activity not found. Please check /Users/[user]/AndroidStudioProjects/[project]/android/app/src/main/AndroidManifest.xml for errors.
No application found for TargetPlatform.android_arm64.
Is your project missing an android/app/src/main/AndroidManifest.xml? Consider running "flutter create ." to create one.
I've checked my AndroidManifest.xml, and it seems correct. The error persists even after ensuring that the package name and target platform are set correctly.
Can someone please provide guidance on how to resolve this issue? What could be causing this error, and what steps should I take to troubleshoot and fix it?
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.webjow.hidden_gallery"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:manageSpaceActivity=".MainActivity"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
tools:replace="android:label"
tools:targetApi="34">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxx~xxxxxxxxxx"/>
<activity
android:name=".MainActivity"
android:theme="@style/LaunchTheme" />
<activity-alias
android:name="OneLauncherAlias"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:targetActivity=".MainActivity"
android:theme="@style/LaunchTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="TwoLauncherAlias"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/calculator"
android:label="@string/app_name_fake"
android:targetActivity=".MainActivity"
android:theme="@style/LaunchTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<!-- 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>
Additional Information:
Flutter version: 3.13.5
and Dart version: 3.1.2
Upvotes: 5
Views: 5717
Reputation: 163
My issue was resolved by adding the namespace in the app/build.gradle file under the android section, like this:
android {
namespace "com.example.your_app_name"
}
Upvotes: 1
Reputation: 88
I don't know why, but the Firebase Code Generation tool destroyed my build.gradle.
The namespace was simply half empty, the generation tool made this out of my working build.gradle
I needed to fix it so it looks like
Upvotes: 1
Reputation: 11
try removing the android folder
then press the "flutter create ." on your terminal. this will regenerate the folder afresh and resolves the problem
flutter create .
Upvotes: 1
Reputation: 138
In my case,I've Solved this issue by adding 'package' attribute in tag 'manifest' it was missing for some reason
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.pachage.name"> <---- here
......
</manifest>
Upvotes: 4
Reputation: 11
This is a bug in the flutter_tools . This plugin code has NO error. You can verify it by generating an apk using flutter build apk.
The error occurs while running by flutter run. It only happens when activity-alias is used as an android.intent.category.LAUNCHER instead of an activity. flutter_tools has no logic to handle activity-alias.
And this is the only way to use multiple app icons in Android.
I am working on a PR to fix this.
Upvotes: 1
Reputation: 431
This worked for me.
Check if namespace "com.webjow.hidden_gallery"
is in your app/build.gradle
Here essentially
android {
namespace "com.webjow.hidden_gallery"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
Upvotes: 4
Reputation: 540
It seems that you have added multiple aliases that are targeting your Main Activity tag.
It can simply be resolved by removing both of the aliases.
Add the intent filter tag in the main activity tag and add a flag of exported true. This will solve the issue.
<activity
android:name=".MainActivity"
android:theme="@style/LaunchTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 3
Reputation: 578
Duplicate <activity-alias>
Elements:
you have defined two <activity-alias>
elements. This is typically not required. You should only have one <activity-alias>
to define the launcher activity.
Remove either the "OneLauncherAlias"
or "TwoLauncherAlias"
<activity-alias>
based on your requirements. The launcher alias should define the entry point of your app.
after that it looks like
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.webjow.hidden_gallery"
xmlns:tools="http://schemas.android.com/tools">
<!-- Your permissions, application, and meta-data here -->
<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:manageSpaceActivity=".MainActivity"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
tools:replace="android:label"
tools:targetApi="34">
<!-- Your activities and other components here -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Upvotes: 1
Reputation: 654
Try this.
Remove intent-filter
from both activity-alias
and add that intent-filter
inside the activity
.
set android:exported="true"
in the activity as well.
<activity
android:name=".MainActivity"
android:theme="@style/LaunchTheme"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity-alias
android:name="OneLauncherAlias"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:targetActivity=".MainActivity"
android:theme="@style/LaunchTheme" />
<activity-alias
android:name="TwoLauncherAlias"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/calculator"
android:label="@string/app_name_fake"
android:targetActivity=".MainActivity"
android:theme="@style/LaunchTheme" />
Upvotes: 1