【问题标题】:Android Ionic Cordova - Error: Failed to get absolute path to installed moduleAndroid Ionic Cordova - 错误:无法获取已安装模块的绝对路径
【发布时间】:2017-08-03 04:53:49
【问题描述】:

我已经创建了一个自定义插件,我正在尝试通过 cmd 来添加它,得到以下错误

> cordova plugin add C:\r\work\custom_plugins\cordova-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:\r\work\custom_plugins\cordova-plugin-webrtc-video-call --s... (exit
        code 1):

        Error: Failed to get absolute path to installed module


C:\r\work>

config.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

【问题讨论】:

    标签: android cordova ionic-framework ionic2 cordova-plugins


    【解决方案1】:

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

    cordova plugin add C:\r\work\custom_plugins\cordova-plugin-webrtc-video-call --nofetch

    希望对您有所帮助。 :)

    【讨论】:

      【解决方案2】:

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

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

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

      cordova plugin remove cordova-plugin-webrtc-video-call --force
      cordova plugin add C:\r\work\custom_plugins\cordova-plugin-webrtc-video-call
      

      (-save 在cordova 7 中似乎没用,因为插件被添加到 config.xml 没有那个)

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

      1. 删除插件文件夹
      2. 删除platforms/android文件夹
      3. 删除 config.xml 中的所有插件引用
      4. 将所有插件重新添加到项目中

      ps:你插件中的xml文件是plugin.xml而不是config.xml吧?

      【讨论】:

      • 我为什么要删除平台和我其他的插件,因为重新创建平台需要很大的时间(〜20分钟)。我已经尝试使用 --force 选项删除您的一个命令,但它仍然无法正常工作谢谢
      • 我不是说你应该这样做,只是我这样做了;)我的问题是重新安装我自己的插件时,我有脚本来重新添加所有插件并重新创建平台立刻。也许问题出在 plugin.xml 或 package.json 文件上?
      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-07-13
        • 2016-04-07
        • 1970-01-01
        • 2020-05-05
        • 2020-08-24
        • 1970-01-01
        • 2019-08-12
        • 2022-10-24
        相关资源
        最近更新 更多