当前位置: 首页 > 知识库问答 >
问题:

Phonegap 3.5自定义插件开发:错误"找不到导入org.apache.cordova.Plugin"

申屠秦斩
2023-03-14

我正试图在PG 3.5上为Android开发一个简单的echo插件。然而,我遇到了上述错误。下面是“cordova构建”的完整跟踪。我怎样才能解决这个问题?


    Running command: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\cordova\build.bat 
    Buildfile: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\build.xml

    -set-mode-check:

    -set-debug-files:

    -check-env:
     [checkenv] Android SDK Tools Revision 22.6.0
     [checkenv] Installed at C:\adt-bundle-windows-x86_64-20131030\android-sdk

    -setup:
         [echo] Project Name: PhoneGapTest
      [gettype] Project Type: Application

    -set-debug-mode:

    -debug-obfuscation-check:

    -pre-build:

    -build-setup:
    [getbuildtools] Using latest Build Tools: 19.0.0
         [echo] Resolving Build Target for PhoneGapTest...
    [gettarget] Project Target:   Android 4.4.2
    [gettarget] API level:        19
         [echo] ----------
         [echo] Creating output directories if needed...
         [echo] ----------
         [echo] Resolving Dependencies for PhoneGapTest...
    [dependency] Library dependencies:
    [dependency] 
    [dependency] ------------------
    [dependency] Ordered libraries:
    [dependency] 
    [dependency] ------------------
         [echo] ----------
         [echo] Building Libraries with 'debug'...

    nodeps:

    -set-mode-check:

    -set-debug-files:

    -check-env:
     [checkenv] Android SDK Tools Revision 22.6.0
     [checkenv] Installed at C:\adt-bundle-windows-x86_64-20131030\android-sdk

    -setup:
         [echo] Project Name: CordovaLib
      [gettype] Project Type: Android Library

    -set-debug-mode:

    -debug-obfuscation-check:

    -pre-build:

    -build-setup:
    [getbuildtools] Using latest Build Tools: 19.0.0
         [echo] Resolving Build Target for CordovaLib...
    [gettarget] Project Target:   Android 4.4.2
    [gettarget] API level:        19
         [echo] ----------
         [echo] Creating output directories if needed...
         [echo] ----------
         [echo] Resolving Dependencies for CordovaLib...
    [dependency] Library dependencies:
    [dependency] No Libraries
    [dependency] 
    [dependency] ------------------

    -code-gen:
    [mergemanifest] Found Deleted Target File
    [mergemanifest] Merging AndroidManifest files into one.
    [mergemanifest] Manifest merger disabled. Using project manifest only.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files...
         [echo] ----------
         [echo] Handling Resources...
         [aapt] Found new input file
         [aapt] Generating resource IDs...
         [echo] ----------
         [echo] Handling BuildConfig class...
    [buildconfig] No need to generate new BuildConfig.

    -pre-compile:

    -compile:
         [echo] Creating library output jar file...

    -post-compile:

    -obfuscate:

    -dex:
         [echo] Library project: do not convert bytecode...

    -crunch:
       [crunch] Crunching PNG Files in source dir: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\res
       [crunch] To destination dir: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\res
       [crunch] Crunched 0 PNG files to update cache

    -package-resources:
         [echo] Library project: do not package resources...

    -package:
         [echo] Library project: do not package apk...

    -post-package:

    -do-debug:
         [echo] Library project: do not create apk...
    [propertyfile] Updating property file: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\build.prop

    -post-build:

    debug:

    -code-gen:
    [mergemanifest] Found Deleted Target File
    [mergemanifest] Merging AndroidManifest files into one.
    [mergemanifest] Manifest merger disabled. Using project manifest only.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files...
         [echo] ----------
         [echo] Handling Resources...
         [aapt] Found Deleted Target File
         [aapt] Generating resource IDs...
         [echo] ----------
         [echo] Handling BuildConfig class...
    [buildconfig] No need to generate new BuildConfig.

    -pre-compile:
         [echo] Set jars path to: C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\CordovaLib\ant-build\classes.jar

    -compile:
        [javac] Compiling 4 source files to C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\ant-build\classes
        [javac] C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\src\org\apache\cordova\plugin\Echo.java:3: error: cannot find symbol
        [javac] import org.apache.cordova.Plugin;
        [javac]                          ^
        [javac]   symbol:   class Plugin
        [javac]   location: package org.apache.cordova
        [javac] C:\Users\virgil\projects\Installerconnect2\sw\phonegapexperiments\platforms\android\src\org\apache\cordova\plugin\Echo.java:12: error: cannot find symbol
        [javac] public class Echo extends Plugin {
        [javac]                           ^
        [javac]   symbol: class Plugin
        [javac] 2 errors

共有1个答案

魏翰
2023-03-14

你应该导入和扩展CordovaPlugin,而不是Plugin。

 类似资料:
  • 我在Project中创建了一个简单的gradle插件。根据文档,它应该是好的,但当我尝试使用它时,我发现id为'show-date-plugin'的文档我指的是:https://docs.gradle.org/current/userguide/custom_plugins.html 您可以将插件的源代码放在rootprojectdir/buildsrc/src/main/groovy目录中。Gr

  • 当我运行我开发的插件时,我得到了一个插件异常。 大概是缺少了一些东西,或者没有绑定什么的--我使用的是基本的build.gradle文件和一个非常普通的plugins.xml文件,所以我不确定哪里出了问题? (另外,如果有人想做一个插件教程,老实说,我现在只需要花很多钱就可以了,实际的文档是垃圾!)

  • 我试着构建应用程序,但一直在获取/Users/gouravkarwasara/Desktop/News2/app/build/generated/source/kapt/debug/com/gourav/news/DataBinderMapperImpl。java:9:错误:找不到符号导入com。古拉夫。消息数据绑定。ActivityDetailBindingImpl;^符号:类ActivityD

  • 我已将google AdMob添加到项目中,并发现以下错误:错误:找不到符号导入com。谷歌。Androidgms。ads.alad;^符号:class Interstitalad位置:package com。谷歌。Androidgms。广告

  • 我试图使用作曲家在wordpress插件中自动加载我的类。 我希望我的模型和控制器驻留在GD名称空间中,但是我希望将我的模型和控制器放入它们自己的目录中。 我面临错误消息:致命错误: 目录/文件结构 创作者json 供应商/编写器/自动加载_名称空间。php GD/src/App.php GD/src/controllers/ShortcodeController。php 我应该使用自动加载类映射

  • 需求分析 使用自定义组件进行场景搭建首先需要以下几点: 跟客户进行深入的讨论和研究,确定客户的需求。 通过手绘或者电脑绘制出大致的样式,继续跟客户确定是否可行。 通过美术组对之前绘制的图形进行美化、加工和配色。 拿到美术组绘制的图片后,确定下实施的方案。 确定数据格式。 ===> (非常重要,如果数据不对极易出现双方返工的现象) 通过 JavaScript 脚本来实现。 由于已经确定好客户的需求,