Closed kouroku-room closed 5 months ago
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.
I will add this in the README.md
Thank you for your prompt reply! I knew there was someone working on PR, but I didn't recognize you as the same as the author of the library😂. I wish your PR success!
Thank you for this package @SNNafi
I'm somehow stuck here... I have two icons
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="${applicationName}">
<activity-alias
android:name="appicon.DEFAULT"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="MYAPP"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="appicon.MYAPP"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher2"
android:label="MYAPP"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<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"
/>
</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>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
DEBUG CONSOLE
Launching lib\main.dart on YAL L21 in debug mode...
package identifier or launch activity not found.
Please check C:\flutter apps\myapp\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 have a temporary solution
You can add the following code in the activity
<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>
When running for the first time, there is no need to comment out the code in the <intent-filter>
.
After the application is running, comment out the <intent-filter>
and then run flutter run
This completes the development environment run
But this is not perfect. The perfect way still requires the author's PR success
The readme for pub.dev includes the following.
At this time, Flutter is unable to
flutter run
a main activity that LAUNCHER has been removed due to this issue. https://github.com/flutter/flutter/issues/38965This issue can be reproduced in the sample app from this repository.
Log after
flutter run
in sample app:I noticed that
<intent-filter>
is only required on the first 'flutter run' after 'flutter clean', and on subsequentflutter run
, no error occurs even if LAUNCHER is commented out. Therefore, I now operate with it commented out and only uncomment it when this error appears.Can you please add to the readme that because of this issue, removing LAUNCHER will cause an error in the use of
flutter run
? Or could you change the Readme from deleting LANUCHER to commenting out, and change to uncomment out only if an error occurs? (Or runflutter build apk --debug
once)Of course, we can get to this Issue by searching for the error text, but I think it would be more helpful if it were mentioned in the Readme from the beginning!