安卓离子科尔多瓦 - 错误:无法获取已安装模块的绝对路径



>我已经创建了一个自定义插件,我正在尝试通过 cmd 添加它,导致错误

> cordova plugin add C:rworkcustom_pluginscordova-plugin-webrtc-video-call -
-save
x Running command - failed!
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova plugin add
C:rworkcustom_pluginscordova-plugin-webrtc-video-call --s... (exit
code 1):
Error: Failed to get absolute path to installed module

C:rwork>

配置.xml

<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-webrtc-video-call" version="1.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>WebrtcVideoCall</name>
<js-module name="WebrtcVideoCall" src="www/WebrtcVideoCall.js">
<clobbers target="cordova.plugins.WebrtcVideoCall" />
</js-module>
<platform name="android">
<config-file parent="/*" target="res/xml/config.xml">
<feature name="WebrtcVideoCall">
<param name="android-package" value="com.hsc.plugin.webrtc.WebrtcVideoCall" />
</feature>
</config-file>
<config-file parent="/manifest/application" target="AndroidManifest.xml">
<activity
android:name="com.hsc.plugin.webrtc.CallActivity"
android:screenOrientation="fullUser"
android:configChanges="orientation|screenSize"
android:exported="true"
android:theme="@style/CallActivityTheme">
<intent-filter>
<action android:name="com.hsc.plugin.ACTION_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-feature android:name="android.hardware.camera" required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="false"
/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
</config-file>
<framework src="src/android/Webrtc.gradle" custom="true" type="gradleReference"/>
<source-file src="src/android/AppRTCAudioManager.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/AppRTCClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/AppRTCProximitySensor.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/CallActivity.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/CallFragment.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/CaptureQualityController.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/CpuMonitor.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/DirectRTCClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/HudFragment.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/PeerConnectionClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/PercentFrameLayout.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/RoomParametersFetcher.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/TCPChannelClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/UnhandledExceptionHandler.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/WebrtcVideoCall.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/WebSocketChannelClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/WebSocketRTCClient.java" target-dir="src/com/hsc/plugin/webrtc" />
<source-file src="src/android/util/AppRTCUtils.java" target-dir="src/com/hsc/plugin/webrtc/util" />
<source-file src="src/android/util/AsyncHttpURLConnection.java" target-dir="src/com/hsc/plugin/webrtc/util" />
<source-file src="src/android/libs/autobanh.jar" target-dir="libs" framework="true" />
<source-file src="src/android/libs/libjingle-peerconnection-sources.jar" target-dir="libs" framework="true" />
<source-file src="src/android/libs/libjingle-peerconnection.jar" target-dir="libs" framework="true" />
<source-file src="src/android/libs/armeabi-v7a/libjingle_peerconnection_so.so" target-dir="libs/armeabi-v7a" 
framework="true" />
<!--  drawable src/android/resources -->
<resource-file src="src/android/res/drawable-hdpi/disconnect.png" target="res/drawable-hdpi/disconnect.png" />
<resource-file src="src/android/res/drawable-mdpi/disconnect.png" target="res/drawable-mdpi/disconnect.png" />
<resource-file src="src/android/res/drawable-xhdpi/disconnect.png" target="res/drawable-xhdpi/disconnect.png" />
<resource-file src="src/android/res/drawable-ldpi/disconnect.png" target="res/drawable-ldpi/disconnect.png" />
<resource-file src="src/android/res/layout/activity_call.xml" target="res/layout/activity_call.xml" />
<resource-file src="src/android/res/layout/fragment_call.xml" target="res/layout/fragment_call.xml" />
<resource-file src="src/android/res/layout/fragment_hud.xml" target="res/layout/fragment_hud.xml" />
<resource-file src="src/android/res/values/WebrtcPluginStrings.xml" target="res/values/WebrtcPluginStrings.xml" />
<resource-file src="src/android/res/values/WebrtcPluginStyles.xml" target="res/values/WebrtcPluginStyles.xml" />
<resource-file src="src/android/res/drawable-hdpi/ic_action_full_screen.png" target="res/drawable-hdpi/iic_action_full_screen.png" />
<resource-file src="src/android/res/drawable-mdpi/ic_action_full_screen.png" target="res/drawable-mdpi/ic_action_full_screen.png" />
<resource-file src="src/android/res/drawable-xhdpi/ic_action_full_screen.png" target="res/drawable-xhdpi/ic_action_full_screen.png" />
<resource-file src="src/android/res/drawable-ldpi/ic_action_full_screen.png" target="res/drawable-ldpi/ic_action_full_screen.png" />
<resource-file src="src/android/res/drawable-hdpi/ic_action_return_from_full_screen.png" target="res/drawable-hdpi/ic_action_return_from_full_screen.png" />
<resource-file src="src/android/res/drawable-mdpi/ic_action_return_from_full_screen.png" target="res/drawable-mdpi/ic_action_return_from_full_screen.png" />
<resource-file src="src/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png" target="res/drawable-xhdpi/ic_action_return_from_full_screen.png" />
<resource-file src="src/android/res/drawable-ldpi/ic_action_return_from_full_screen.png" target="res/drawable-ldpi/ic_action_return_from_full_screen.png" />

</platform>
</plugin>

我已经尝试过 --nofetch 选项,我正在使用 cordova v7.0.1

确保没有要安装node_modules插件的文件/符号链接。如果存在,请删除它们并重新运行命令:

cordova plugin add C:rworkcustom_pluginscordova-plugin-webrtc-video-call --nofetch

希望有帮助。 :)

SO上有几篇关于这个问题的帖子。

在您用于安装插件的本地路径和配置中有关该插件的信息之间.xml cordova 似乎丢失了。

有些人似乎通过首先删除带有 --force 标志的插件然后重新安装来修复它:

cordova plugin remove cordova-plugin-webrtc-video-call --force
cordova plugin add C:rworkcustom_pluginscordova-plugin-webrtc-video-call

(-save 在 Cordova 7 中似乎毫无用处,因为插件被添加到 config 中.xml没有它(

当我遇到问题时,我通过清除项目中的所有插件并重新添加插件来修复它:

  1. 删除插件文件夹
  2. 删除平台/安卓文件夹
  3. 删除配置中的所有插件引用.xml
  4. 将所有插件重新添加到项目中

PS:插件中的XML文件名为插件.xml而不是config.xml,对吧?

--nofetch选项是解决问题的方法,如下所示:https://stackoverflow.com/a/46010348/327862

但是,从 Cordova 8.0.0 开始,--nofetch选项已被删除:https://issues.apache.org/jira/browse/CB-13055

如果您已经安装了 Cordova 8.x.x 并希望使用--nofetch选项,那么您需要将 cordova 降级到 7.1.0。

运行以下命令将 Cordova 降级到 7.1.0:

npm install -g cordova@7.1.0

如果上述命令不起作用,则首先尝试卸载 cordova,然后安装 cordova 版本 7.1.0:

npm uninstall -g cordova
npm install -g cordova@7.1.0

然后,检查Cordova版本以确认它是否已降级:

cordova --version

相关内容

  • 没有找到相关文章

最新更新