image_pickers icon indicating copy to clipboard operation
image_pickers copied to clipboard

插件冲突

Open DaYang816 opened this issue 8 months ago • 10 comments

您好,我在接入广告插件的时候发现冲突,请问有什么建议么。

E:\flutterDemo\ces\android\app\src\debug\AndroidManifest.xml:26:9-60 Error:
	Attribute application@networkSecurityConfig value=(@xml/network_config) from [:flutter_gromore_ads] AndroidManifest.xml:26:9-60
	is also present at [:image_pickers] AndroidManifest.xml:34:9-53 value=(@xml/net_sec).
	Suggestion: add 'tools:replace="android:networkSecurityConfig"' to <application> element at AndroidManifest.xml:14:5-48:19 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Attribute application@networkSecurityConfig value=(@xml/network_config) from [:flutter_gromore_ads] AndroidManifest.xml:26:9-60
  	is also present at [:image_pickers] AndroidManifest.xml:34:9-53 value=(@xml/net_sec).
  	Suggestion: add 'tools:replace="android:networkSecurityConfig"' to <application> element at AndroidManifest.xml:14:5-48:19 to override.

DaYang816 avatar Dec 23 '23 07:12 DaYang816

报错提示 上面 写着呢  在你项目的 AndroidManifest.xml 中添加 tools:replace="android:networkSecurityConfig"

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年12月23日(星期六) 下午3:21 收件人: @.>; 抄送: @.***>; 主题: [lisen87/image_pickers] 插件冲突 (Issue #136)

您好,我在接入广告插件的时候发现冲突,请问有什么建议么。 E:\flutterDemo\ces\android\app\src\debug\AndroidManifest.xml:26:9-60 Error: Attribute @.*** @./network_config) from [:flutter_gromore_ads] AndroidManifest.xml:26:9-60 is also present at [:image_pickers] AndroidManifest.xml:34:9-53 @./net_sec). Suggestion: add 'tools:replace="android:networkSecurityConfig"' to <application> element at AndroidManifest.xml:14:5-48:19 to override. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugMainManifest'. > Manifest merger failed : Attribute @.*** @./network_config) from [:flutter_gromore_ads] AndroidManifest.xml:26:9-60 is also present at [:image_pickers] AndroidManifest.xml:34:9-53 @./net_sec). Suggestion: add 'tools:replace="android:networkSecurityConfig"' to <application> element at AndroidManifest.xml:14:5-48:19 to override.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

lisen87 avatar Dec 23 '23 07:12 lisen87

这个提示我加过了,直接构建失败了

    <application
        android:label="测试"
        android:name="${applicationName}"
        tools:replace="android:theme"
        android:theme="@style/AppTheme"
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:networkSecurityConfig">

日志

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: Error parsing E:\flutterDemo\ai_miao_ying\android\app\src\main\AndroidManifest.xml

* 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 14s
Exception: Gradle task assembleDebug failed with exit code 1

DaYang816 avatar Dec 23 '23 07:12 DaYang816

只能有一个 tools:replace,这样写 tools:replace="android:theme,android:networkSecurityConfig"

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年12月23日(星期六) 下午3:27 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [lisen87/image_pickers] 插件冲突 (Issue #136)

这个提示我加过了,直接构建失败了 <application android:label="测试" android:name="${applicationName}" tools:replace="android:theme" @./AppTheme" @./ic_launcher" tools:replace="android:networkSecurityConfig">
日志 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugMainManifest'. > com.android.manifmerger.ManifestMerger2$MergeFailureException: Error parsing E:\flutterDemo\ai_miao_ying\android\app\src\main\AndroidManifest.xml * 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 14s Exception: Gradle task assembleDebug failed with exit code 1
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

lisen87 avatar Dec 23 '23 07:12 lisen87

image

lisen87 avatar Dec 23 '23 07:12 lisen87

感谢您的回复,它报了新的错误

E:\flutterDemo\ces\android\app\src\main\AndroidManifest.xml:14:5-48:19 Error:
	tools:replace specified at line:14 for attribute android:networkSecurityConfig, but no new value specified
E:\flutterDemo\ces\android\app\src\main\AndroidManifest.xml Error:
	Validation failed, exiting

DaYang816 avatar Dec 23 '23 07:12 DaYang816

这是我的完整配置

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <!-- 网络 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 检查wifi网络状态 -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 开关Wi-Fi状态,解决中国内地机型移动网络权限问题需要 -->
    <!--网络状态-->
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <!-- 储存 -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application
        android:label="测试"
        android:name="${applicationName}"
        tools:replace="android:theme,android:networkSecurityConfig"
        android:theme="@style/AppTheme"
        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"
            android:screenOrientation="portrait">
            <!-- 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>

DaYang816 avatar Dec 23 '23 07:12 DaYang816

您好,我看到一个关闭的issue #98 我自己fork插件然后去删除这行,这个相关操作会影响到插件的运行么

DaYang816 avatar Dec 23 '23 07:12 DaYang816

这个是不会影响的,可以先这么解决的

lisen87 avatar Dec 23 '23 07:12 lisen87

如果不想 fork的话,可以尝试 在自己项目中 添加 networkSecurityConfig配置,然后通过tools:replace去替换,这样应该是可以的

lisen87 avatar Dec 23 '23 07:12 lisen87

感谢您的回复,我自己参考2个插件的配置设置了一下可以运行了。

DaYang816 avatar Dec 23 '23 07:12 DaYang816