Ionic Plugin Document Viewer Creating Android Manifest Merger Issue In Build

Here is the info related to the Ionic Project I am working on.

global packages:

    @ionic/cli-utils : 1.1.2
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.1.2

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.1.2
    @ionic/cli-plugin-ionic-angular : 1.1.2
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v6.9.5
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed

The app was running and building fine till I added this plugin. Once I add the plugin it failed. I can see the FILE PROVIDER multiple times in the manifest file and I think it is what causing the merger error.

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.conferenceapp" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@style/Theme.AppCompat.Light" />
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
        </provider>
        <provider android:authorities="io.ionic.conferenceapp.DocumentViewerPlugin.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/documentviewer_file_paths" />
        </provider>
        <activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden|screenSize" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" />
        <activity android:label="Share" android:name="com.google.zxing.client.android.encode.EncodeActivity" />
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-feature android:name="android.hardware.camera" android:required="true" />
</manifest>

Need community advice on this one.

What other plugins do you have installed in the project? (ionic cordova plugin list)
What was the config.xml before you added this plugin?
What exactly is the error you are getting and when exactly (command)?

Hi Sujan, Please find the attached Info.

Plugins Used

image

<?xml version='1.0' encoding='utf-8'?>

    RMS Mobile
    
        An Ionic Framework application for the Ionic Conference.
  
    
      Ionic Framework Team
  
    
    
    
    
    
    
    
    
    
    
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
        
        
        
        
        
    
    
    
    
    
    
    
    
    
    

I am running the following command and I get the following error

ionic cordova run android
UP-TO-DATE
:generateArmv7DebugResources UP-TO-DATE
:mergeArmv7DebugResources
 UP-TO-DATE

:processArmv7DebugManifest
C:\Users\mohan\Documents\PrimusGIT\MobileApps\Demo\platforms\android\AndroidManifest.xml:16:9-18:20 Error:
        Element provider#android.support.v4.content.FileProvider at AndroidManifest.xml:16:9-18:20 duplicated with element declared at AndroidManifest.xml:13:9-15:20


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

:processArmv7DebugManifest FAILED

C:\Users\mohan\Documents\PrimusGIT\MobileApps\Demo\platforms\android\AndroidManifest.xml Error:
        Validation failed, exiting


BUILD FAILED

Total time: 27.006 secs
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processArmv7DebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
C:\Users\mohan\Documents\PrimusGIT\MobileApps\Demo\platforms\android\AndroidManifest.xml:16:9-18:20 Error:
        Element provider#android.support.v4.content.FileProvider at AndroidManifest.xml:16:9-18:20 duplicated with element declared at AndroidManifest.xml:13:9-15:20
C:\Users\mohan\Documents\PrimusGIT\MobileApps\Demo\platforms\android\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processArmv7DebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run android (exit code 1).

Thanks,
Mohan

So it’s [quote=“mkodali, post:1, topic:91297”]
<provider android:authorities=“${applicationId}.provider” android:exported=“false” android:grantUriPermissions=“true” android:name=“android.support.v4.content.FileProvider”>
<meta-data android:name=“android.support.FILE_PROVIDER_PATHS” android:resource=“@xml/provider_paths” />
</provider>
[/quote]
vs.

. The second seems to be added by the Document-Viewer-Plugin. Do you know what created the first one?

Sundeep, I think it could be either Image Picker or the Camera Plugin. Let me check that by uninstalling one by one… meanwhile let me know what you think.

Sundeep, its the Camera Plugin as we thought.

So now the question is what to do about it. Can you remove the first one and both still work?

Here someone has a similar problem: https://stackoverflow.com/questions/34510751/cordova-android-duplicated-uses-feature-from-two-plugins
Or here: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/295

Here is actually your exact problem: https://stackoverflow.com/questions/40746144/error-with-duplicated-fileprovider-in-manifest-xml-with-cordova/41550634#41550634 Unfortunately the solution is hacking the plugin… But that would work at least.

And here is a Cordova issue that could use some Votes so it gets looked at as it could maybe solve this problem easier: https://issues.apache.org/jira/browse/CB-8401

(And that was my Google mojo for today…)

Thanks for your help Sujan. I took out Camera as I dont need it in the app at this point of time. Thanks a bunch.

1 Like

As the linked issue wasn’t a perfect match I just created a new one:
https://issues.apache.org/jira/browse/CB-12842

Hi , i have the same issue here, its for android 12