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

Ionic修改AppMeasurementInstallReferrerReceiver权限配置报错如何解决?

解决方案

你遇到的配置报错和安全规则未生效问题,可按照以下步骤修正config.xml配置:

  • 修正权限配置的目标节点错误:权限声明需归属manifest根节点,你当前将<uses-permission>放在/manifest/application目标下属于语法错误,需调整target属性。
  • 合并重复的application属性配置:下拆分的3个<application>节点需合并为一个,避免节点冲突导致编译报错。
  • 修正类名书写错误:com.google.firebase.auth.internal.FederatedSignInActivity前多写了.前缀,会被识别为应用本地类,删除多余的.即可。
  • 调整广播接收器的配置模式:merge模式不会覆盖已存在的同名称组件属性,改为overwrite模式即可强制覆盖原有exported=true的默认配置。
  • 移除无效权限声明:android.permission.INSTALL_PACKAGES为系统签名级权限,普通第三方应用无法获取,无需给对应广播接收器添加该权限属性,仅设置android:exported="false"即可满足安全扫描要求。
  • 删除重复的广播接收器配置:你已经在全局Android配置中添加过AppMeasurementInstallReferrerReceiver的配置,重复添加会触发节点冲突报错。

修正后的Android平台配置示例

<platform name="android">
    <hook src="hooks/add_tools_namespace.js" type="after_prepare" />
    <allow-intent href="market:*" />
    <allow-navigation href="*" />
    <allow-intent href="*" />
    <access origin="*" />
    <!-- 图标、启动屏配置保持不变 -->
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
    <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
    <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
    <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
    <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
    <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
    <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
    <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
    <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
    <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
    <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
    <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
    <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    
    <!-- 合并application属性配置 -->
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application 
            android:usesCleartextTraffic="false" 
            android:requestLegacyExternalStorage="true" 
            android:allowBackup="false" 
            tools:replace="android:allowBackup" />
    </edit-config>
    
    <!-- 权限配置调整target为manifest -->
    <config-file file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest">
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    </config-file>
    
    <config-file file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <activity android:exported="false" android:name="com.google.android.gms.tagmanager.TagManagerPreviewActivity" android:noHistory="true" />
    </config-file>
    
    <!-- 广播接收器配置改为overwrite模式,移除无效权限属性 -->
    <config-file file="app/src/main/AndroidManifest.xml" mode="overwrite" target="/manifest/application">
        <receiver android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" />
    </config-file>
    
    <config-file file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <receiver android:enabled="true" android:exported="false" android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND" />
    </config-file>
    
    <!-- 合并重复的FederatedSignInActivity配置,修正类名错误 -->
    <config-file file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <activity android:name="com.google.firebase.auth.internal.FederatedSignInActivity" tools:replace="android:exported" android:exported="false" android:permission="com.google.firebase.auth.api.gms.permission.LAUNCH_FEDERATED_SIGN_IN" />
    </config-file>
    
    <config-file file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.auth.api.signin.RevocationBoundService" android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
    </config-file>
</platform>

后续构建操作

修改完成后执行以下命令清理缓存后重新构建即可:

ionic cordova platform rm android
ionic cordova platform add android
ionic cordova build android

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 10:39:04