简体   繁体   中英

Ionic 3 : Android add platform fails after installing cordova-plugin-camera and Native Web-intent

And first of all, thank you for the time you'll take to help me!

Summary:

Tried to add the cordova-plugin-camera to my ionic 3 project. After many fails and finally a success, now my app does not build on my android anymore.

-------- START EDIT --------

After much tests, it seems that there is a conflict/issue when I have both plugins camera and web-intent installed.

Both plugins are from Ionic Native:

-------- END EDIT --------

My ionic Info

    cli packages: (C:\Users\[...]\AppData\Roaming\npm\node_modules)
        @ionic/cli-utils  : 1.9.2
        ionic (Ionic CLI) : 3.9.2
    global packages:
        Cordova CLI : 7.0.1
    local packages:
        @ionic/app-scripts : 2.1.3
        Cordova Platforms  : android 6.2.3
        Ionic Framework    : ionic-angular 3.6.0
    System:
        Node : v8.1.2
        npm  : 5.0.3
        OS   : Windows 10

Steps I took (a little history):

I could not install the camera plugin due to an incompatible version of the cordova-plugin-compat (can be found in lots of forums). So I've followed some of the steps:

  • removed the cordova-plugin-compat v1.0.0 --force
  • installed latest version of cordova-plugin-compat@1.1.0
  • --> run android : My app still worked and runs on my device (check!)

Then I try to install the camera plugin :

  • ionic cordova plugin add cordova-plugin-camera
  • Here is what I got back:

     > cordova plugin add cordova-plugin-camera --save × Running command - failed! [ERROR] An error occurred while running cordova plugin add cordova-plugin-camera --save (exit code 1): Installing "cordova-plugin-camera" for android Plugin dependency "cordova-plugin-compat@1.1.0" already fetched, using that version. Dependent plugin "cordova-plugin-compat" already installed on android. [...] BUILD SUCCESSFUL Error during processing of action! Attempting to revert... Failed to install 'cordova-plugin-camera': Error at copyNewFile (C:\\[...]\\platforms\\android\\cordova\\lib\\pluginHandlers.js:248:15) at install (C:\\[...]\\platforms\\android\\cordova\\lib\\pluginHandlers.js:43:17) at ActionStack.process (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\ActionStack.js:56:25) at PluginManager.doOperation (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\PluginManager.js:117:20) at PluginManager.addPlugin (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\PluginManager.js:147:17) at C:\\[...]\\platforms\\android\\cordova\\Api.js:254:18 at _fulfilled (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:854:54) at self.promiseDispatch.done (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:883:30) at Promise.promise.promiseDispatch (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:816:13) at C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:624:44 Error: Uh oh! "C:\\[...]\\platforms\\android\\res\\xml\\provider_paths.xml" already exists! 

So then, I continued following steps I've seen in other threads about the camera plugin issue:

  • remove the android platform
  • ionic cordova plugin add cordova-plugin-camera
  • --> plugin successfully installed ! (There I think, GREAT!)

So I add back the platform :

  • ionic cordova platform add android
  • and BOOM:

     > cordova platform add android --save × Running command - failed! [ERROR] Exception: Using cordova-fetch for cordova-android@~6.2.2 Adding android project... Creating Cordova project for the Android platform: Path: platforms\\android Package: com.app.app Name: app Activity: MainActivity Android target: android-25 Subproject Path: CordovaLib Android project created with cordova-android@6.2.3 Installing "com-darryncampbell-cordova-plugin-intent" for android Subproject Path: CordovaLib Installing "cordova-plugin-camera" for android Plugin dependency "cordova-plugin-compat@1.1.0" already fetched, using that version. Installing "cordova-plugin-compat" for android Error during processing of action! Attempting to revert... Failed to install 'cordova-plugin-camera': Error at copyNewFile (C:\\[...]\\platforms\\android\\cordova\\lib\\pluginHandlers.js:248:15) at install (C:\\[...]\\platforms\\android\\cordova\\lib\\pluginHandlers.js:43:17) at ActionStack.process (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\ActionStack.js:56:25) at PluginManager.doOperation (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\PluginManager.js:117:20) at PluginManager.addPlugin (C:\\[...]\\platforms\\android\\cordova\\node_modules\\cordova-common\\src\\PluginManager.js:147:17) at C:\\[...]\\platforms\\android\\cordova\\Api.js:254:18 at _fulfilled (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:854:54) at self.promiseDispatch.done (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:883:30) at Promise.promise.promiseDispatch (C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:816:13) at C:\\[...]\\platforms\\android\\cordova\\node_modules\\q\\q.js:570:49 Error: Uh oh! "C:\\[...]\\platforms\\android\\res\\xml\\provider_paths.xml" already exists! 

Final step, I've run npm install -g cordova ionic

    npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
    C:\Users\[...]\AppData\Roaming\npm\ionic -> C:\Users\[...]\AppData\Roaming\npm\node_modules\ionic\bin\ionic
    C:\Users\[...]\AppData\Roaming\npm\cordova -> C:\Users\[...]\AppData\Roaming\npm\node_modules\cordova\bin\cordova
    + ionic@3.9.2
    + cordova@7.0.1
    added 5 packages, removed 6 packages and updated 42 packages in 55.193s

and ionic cordova platform add android again, but now it tells me:

    > cordova platform add android --save
    × Running command - failed!
    [WARN] Platform already added. Saving platforms to config.xml.
    > cordova platform save
    √ Running command - done!

and if I try the ionic cordova run android :

    > cordova platform add android --save
    × Running command - failed!
    [WARN] Platform already added. Saving platforms to config.xml.
    > cordova platform save
    √ Running command - done!
    [INFO] Running app-scripts build: --platform android --target cordova
    [...]
    > ionic cordova prepare
    [WARN] No Cordova platforms listed in config.xml. Nothing to prepare.

    You can save your installed platforms to config.xml with the ionic cordova platform save command.

and ionic cordova platform save command doesn't change a thing.

-------- START EDIT -------- Then I tried creating a brand new project and added the plugins one by one, starting with the camera one, and rebuilding/running on my device after every plug in installed... it all worked fine until the last one, which was the web-intent plug-in and I got the same issue as before :

    Error: Uh oh!
            "C:\[...]\newApp\platforms\android\res\xml\provider_paths.xml" already exists!

Uninstalled it, removed and re added the platform and build, compile and run on device workes again.

-------- END EDIT --------

Here is the list of all the plugins I have:

    com-darryncampbell-cordova-plugin-intent 0.0.14 "Intent Shim"
    cordova-plugin-camera 2.4.1 "Camera"
    cordova-plugin-compat 1.1.0 "Compat"
    cordova-plugin-console 1.0.5 "Console"
    cordova-plugin-device 1.1.4 "Device"
    cordova-plugin-facebook4 1.9.1 "Facebook Connect"
    cordova-plugin-file 4.3.3 "File"
    cordova-plugin-file-transfer 1.6.3 "File Transfer"
    cordova-plugin-photo-library 2.1.0 "Photo Library"
    cordova-plugin-splashscreen 4.0.3 "Splashscreen"
    cordova-plugin-2.2.2 "StatusBar"
    cordova-plugin-whitelist 1.3.1 "Whitelist"
    cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
    ionic-plugin-keyboard 2.2.1 "Keyboard"

Not sure if I need to downgrade Ionic or Cordova CLI, Ionic or cordova platform or anything else to make this work.

Thanks again for your help!

in ionic3 you don't need to add platform

you just run ionic cordova run android it automaticaly addeds it

also this is wrong command their is no such command as far as i know

cordova platform add android --save // wrong command

right one

ionic cordova run android // right command directly add platform and run 

Tip: Open the android project in Android Studio. You might find a more helpful error stack there.

I had the same issue and found out, that the manifest could not be read because of the following line in my config.xml.

<preference name="Orientation" value="all" />

Same thing happned with me for ionic keyboard and i ran below command

To remove the plugin, run the code: cordova plugin remove ionic-plugin-keyboard

And after that removed android platform and added again. It run like a charm now :) Hope it will help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM