You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用安装后设备出现多个相同实例问题求助

Flutter应用安装后出现3个重复启动图标问题排查与解决

问题现象

开发的Flutter应用功能正常,但无论通过Google Play安装还是直接运行安装,设备上都会出现3个完全相同的应用启动图标,且系统将它们视为同一应用。

提供的配置文件

主AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />    
    <application
        android:label="myapp"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:label"
        android:requestLegacyExternalStorage="true">

        <!-- 定时通知相关接收器 -->
        <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
        <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait"
            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"
            android:showWhenLocked="false">
            <!-- Flutter初始化阶段显示的主题配置 -->
            <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>
        <!-- Flutter插件注册所需元数据,请勿删除 -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.USE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="com.android.vending.BILLING" />
</manifest>

app模块build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

android {
    namespace "com.example.myapp"
    compileSdkVersion 34
    ndkVersion "26.1.10909125"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // 请替换为唯一的应用ID
        applicationId "com.example.myapp"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode 1
        versionName '1.0.1'
        multiDexEnabled true
    }

    buildTypes {
        release {
            // 当前使用调试签名,正式发布需替换为正式签名配置
            signingConfig = signingConfigs.debug
            minifyEnabled = false
            shrinkResources = false
        }
        debug {
            minifyEnabled = false
            shrinkResources = false
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'androidx.window:window:1.0.0'
    implementation 'androidx.window:window-java:1.0.0'
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
}

排查方向与解决方法

从提供的配置文件看,主AndroidManifest.xml仅定义了一个带LAUNCHER类别的启动Activity,重复图标大概率由以下原因导致:

  • 构建缓存与变体残留:检查是否存在多构建变体配置,清理缓存后重新打包:
    flutter clean
    flutter build apk --release
    
  • 图标资源重复:检查mipmap目录下是否存在多组同名图标,或不同密度文件夹的图标被系统误识别为不同启动项,确保图标资源统一。
  • 插件Manifest合并冲突:部分Flutter插件可能在Manifest合并时自动添加额外启动项,可逐步移除插件排查(比如先移除flutter_local_notifications),验证是否解决问题。
  • 系统启动器缓存:部分设备启动器缓存会残留旧图标信息,可尝试清除应用数据、重启设备或切换启动器后恢复,消除缓存残留。

内容的提问来源于stack exchange,提问作者Covex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 05:22:08