gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:35:36 27 4
gpt4 key购买 nike

首先,感谢您抽出时间来帮助我!

总结:

尝试将 cordova-plugin-camera 添加到我的 ionic 3 项目中。在多次失败后终于成功,现在我的应用程序不再构建在我的 android 上。

--------开始编辑--------

经过多次测试,当我同时安装插件相机和 web-intent 时,似乎存在冲突/问题。

两个插件均来自 Ionic Native:

-------- 结束编辑--------

我的 ionic 信息

    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

我采取的步骤(一点历史):

由于 cordova-plugin-compat 的版本不兼容(可以在很多论坛中找到),我无法安装相机插件。所以我遵循了一些步骤:

  • 删除了 cordova-plugin-compat v1.0.0 --force
  • 安装了最新版本的 cordova-plugin-compat@1.1.0
  • --> 运行 android:我的应用程序仍然可以在我的设备上运行(检查!)

然后我尝试安装相机插件:

  • ionic cordova 插件添加 cordova-plugin-camera
  • 这是我得到的结果:

    > 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!

那么,我继续按照我在其他线程中看到的有关相机插件问题的步骤进行操作:

  • 移除安卓平台
  • ionic cordova 插件添加 cordova-plugin-camera
  • --> 插件安装成功! (我认为,太棒了!)

所以我加回平台:

  • ionic cordova平台添加android
  • 和繁荣:

    > 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!

最后一步,我运行了 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

ionic cordova platform add android 再次,但现在它告诉我:

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

如果我尝试 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.

ionic cordova platform save 命令没有任何改变。

-------- 开始编辑--------然后我尝试创建一个全新的项目并一个一个地添加插件,从相机开始,然后在安装每个插件后在我的设备上重建/运行……一切正常,直到最后一个,即网络-intent 插件,我遇到了和以前一样的问题:

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

卸载它,删除并重新添加平台,然后在设备上再次构建、编译和运行。

-------- 结束编辑--------

这是我拥有的所有插件的列表:

    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"

不确定我是否需要降级 Ionic 或 Cordova CLI、Ionic 或 cordova 平台或任何其他平台才能使这项工作正常进行。

再次感谢您的帮助!

最佳答案

在ionic3中你不需要添加平台

你只需运行 ionic cordova run android 它会自动添加它

这也是错误的命令,据我所知,他们没有这样的命令

cordova platform add android --save // wrong command

对了

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

关于android - ionic 3 : Android add platform fails after installing cordova-plugin-camera and Native Web-intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46090844/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com