Attribute application@networkSecurityConfig value=(@xml/network_security_config) fromAndroidManifest

Error:
Attribute application@networkSecurityConfig value=(@xml/network_security_config) from AndroidManifest.xml:28:9-69
is also present at [com.tradplusad:tradplus-sdk:12.1.10.1] AndroidManifest.xml:12:18-81 value=(@xml/tp_network_security_config).
Suggestion: add 'tools:replace="android:networkSecurityConfig"' to <application> element at AndroidManifest.xml:19:5-277:19 to override.
这个错误提示说明在你的项目和 com.tradplusad:tradplus-sdk 库中都定义了 networkSecurityConfig 属性。为了解决这个冲突,你需要使用 tools:replace 属性来指定哪个配置应该被替代。
以下是具体的解决步骤:
-
在你的项目的
AndroidManifest.xml文件中,添加tools命名空间:这通常是在<manifest>元素的开头。<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.yourapp"> <!-- 其他内容 --> </manifest> -
在
<application>元素中添加tools:replace="android:networkSecurityConfig":<application android:name=".YourApplicationClass" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" tools:replace="android:networkSecurityConfig" android:networkSecurityConfig="@xml/network_security_config"> <!-- 其他内容 --> </application>
这样做将会告诉构建系统使用你在项目中定义的 @xml/network_security_config 文件,而不是库中定义的 @xml/tp_network_security_config 文件。
完整示例
假设你的 AndroidManifest.xml 如下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.yourapp">
<application
android:name=".YourApplicationClass"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:networkSecurityConfig"
android:networkSecurityConfig="@xml/network_security_config">
<!-- 其他内容 -->
</application>
</manifest>
确保你已经正确配置了你的 network_security_config.xml 文件,以符合你的应用需求。
通过上述步骤,你应该能够解决 Attribute application@networkSecurityConfig value=(@xml/network_security_config) ... is also present at [com.tradplusad:tradplus-sdk:12.1.10.1] 错误。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)