Issue
This is how my XML looks like.
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="xxxxxxxx" android:versionName="xxxxx" package="xxxxxx" xmlns:android="xxxxxxxxxxxxxx">
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
</application>
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
</manifest>
I need to add the below line after the <application
android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true"
So, the output should look like
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="xxxxxxxx" android:versionName="xxxxx" package="xxxxxx" xmlns:android="xxxxxxxxxxxxxx">
<application android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
</application>
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
</manifest>
I've tried sed command but still no luck. everybody suggests to use XMLSTART.
sed -i '/<application/a android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true"' AndroidManifest.xml
Solution
This might look like:
xmlstarlet ed \
-i '/manifest/application' -t attr -n android:networkSecurityConfig -v '@xml/network_security_config' \
-i '/manifest/application' -t attr -n android:requestLegacyExternalStorage -v true \
<in.xml >out.xml
Answered By - Charles Duffy Answer Checked By - Marie Seifert (WPSolving Admin)