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

时间:2014-08-27 04:04:15

标签: android cordova plugins native

我正在尝试在PG 3.5上为Android开发一个简单的echo插件。但是我收到了上述错误。来自" cordova build"在下面。我该如何解决这个问题?


    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 个答案:

答案 0 :(得分:1)

您应该导入和扩展CordovaPlugin,而不是插件。