Cordova-plugin-x-socialsharing-android12 - errors

Using Voltbuilder - trying to rebuild an older app (phonegap build to voltbuilder migrated, last voltbuild summer 2021) - all plugins now build except this one.

EDIT: Have figured another previous plugin is conflicting…

> Task :app:processReleaseMainManifest FAILED
/platforms/android/app/src/main/AndroidManifest.xml:62:5-81 Error:
	Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:62:5-81 duplicated with element declared at AndroidManifest.xml:38:5-108
/platforms/android/app/src/main/AndroidManifest.xml Error:
	Validation failed, exiting


* What went wrong:
Execution failed for task ':app:processReleaseMainManifest'.
> Manifest merger failed with multiple errors, see logs
See log for full details.
2023-10-18 10:18:28,752 - Build failed 27a577cc-397e-4460-9e84-1cec7ec9cf2a
2023-10-18 10:18:30,404 - Output:

We’ve seen this before - oftentimes when projects default to using the latest version of a plugin and multiple plugins change between builds.

The error indicates that more than one thing is editing your AndroidManifest.xml causing duplicated elements. Generally this is either a conflict between a plugin and your config.xml or two plugins. Do you have a list of plugins you’re using and their versions?

<plugin name="cordova-plugin-androidx-adapter" />
<plugin name="cordova-plugin-cleartext" source="npm" /> 

	<!--PHONEGAP PLUGINS-->
	<plugin name="cordova-plugin-media" source="npm" />
	<plugin name="cordova-plugin-device" source="npm" />
	<plugin name="cordova-plugin-dialogs" source="npm" />
	<plugin name="cordova-plugin-globalization" source="npm" />

	<plugin name="cordova-plugin-file" source="npm" />
	<plugin name="cordova-plugin-network-information" source="npm" /> 

    	<plugin name="cordova-plugin-inappbrowser" source="npm" />

    	<plugin name="cordova-plugin-camera" source="npm">
        	<variable name="CAMERA_USAGE_DESCRIPTION" value="This app requires access to your camera to take photos." />
        	<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="This app requires access to your photo library to save photos." />        
    	</plugin>

   	<plugin name="cordova-sqlite-evcore-extbuild-free" source="npm" /> 

	<plugin name="cordova-plugin-local-notification-12" source="npm" /> 

    	<plugin name="cordova-plugin-x-socialsharing-android12" source="npm" />    
         


    <!-- fixes cross origin ppolicy for file:// request in iOS -->    
    <plugin name="@globules-io/cordova-plugin-ios-xhr" source="npm" />

    <!-- fixes transparent status bar with notch on iOS -->
    <plugin name="cordova-plugin-statusbar" source="npm" />
      
    <preference name="StatusBarOverlaysWebView" value="false" />
    <preference name="StatusBarBackgroundColor" value="#734193" />
    <preference name="StatusBarStyle" value="lightcontent" />
      
    <!-- PLUGIN BUILD FIX FOR ANDRIOD -->
    <!-- attr/ttcIndex attr/fontVariationSetting -->
    <plugin name="cordova-android-support-gradle-release" source="npm" />   

Any of those plugins could have updated since your last successful attempt. If you know when your build was last successful I would check to see what’s been updated since that time to limit your search. Then I would start looking at the various plugin.xml files to determine which plugins are setting WRITE_EXTERNAL_STORAGE - you might start with cordova-plugin-file which was recently updated.

I can see cordova-plugin-camera is setting WRITE_EXTERNAL_STORAGE - in this instance, what is then the fix?

both cordova-plugin-x-socialsharing-android12 and cordova-plugin-camera are setting WRITE_EXTERNAL_STORAGE.

        <config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
            <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
            <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
        </config-file>

Can you see if you get the same error if you use version 6.0.0 of cordova-plugin-camera?

This may create other issues, but it will give me some idea of why this suddenly started happening.

Fixing camera to spec 6.0.0 published - but I haven’t been able to test it as my dev android device is older than the last build of this app!

EDIT: I’ve been able to install on a colleagues phone, and the camera functionality works, and also the social sharing. Next step to test iOS build once I’m given certificate permission.