适用于Android的失败构建Cordova

时间:2015-01-06 00:32:20

标签: android cordova build cordova-3

失败的构建Cordova for Android。

这是为了构建应用程序Cordova。

我正在使用:
- Java jdk和jre 7 U72
- cordova@4.1.2
- Ant 1.9.4

Bash_profile文件配置了android sdk的方式。

MacBook:hello marcelo$ cordova run android

Running command: /Path/local/hello/platforms/android/cordova/run 
Buildfile: /Path/local/hello/platforms/android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.0.2
 [checkenv] Installed at /ARQUIVOS/AndroidSDK/Mac

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
     [echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target:   Android 2.2
[gettarget] API level:        8
[gettarget] WARNING: Attribute minSdkVersion in AndroidManifest.xml (10) is higher than the project target API level (8)
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build/res
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build/rsObj
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build/rsLibs
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-gen
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build/classes
    [mkdir] Created dir: /Path/local/hello/platforms/android/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
     [echo] ----------
     [echo] Building Libraries with 'debug'...

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.0.2
 [checkenv] Installed at /ARQUIVOS/AndroidSDK/Mac

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
     [echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target:   Android 2.2
[gettarget] API level:        8
[gettarget] WARNING: Attribute minSdkVersion in AndroidManifest.xml (10) is higher than the project target API level (8)
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/res
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/libs
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build/res
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build/rsObj
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build/rsLibs
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-gen
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build/classes
    [mkdir] Created dir: /Path/local/hello/platforms/android/CordovaLib/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.

-code-gen:
[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] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 93 source files to /Path/local/hello/platforms/android/CordovaLib/ant-build/classes
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java:21: error: cannot find symbol
    [javac] import android.webkit.JavascriptInterface;
    [javac]                      ^
    [javac]   symbol:   class JavascriptInterface
    [javac]   location: package android.webkit
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:31: error: cannot find symbol
    [javac] import android.webkit.WebResourceResponse;
    [javac]                      ^
    [javac]   symbol:   class WebResourceResponse
    [javac]   location: package android.webkit
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:49: error: cannot find symbol
    [javac]     public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    [javac]            ^
    [javac]   symbol:   class WebResourceResponse
    [javac]   location: class IceCreamCordovaWebViewClient
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:266: error: cannot find symbol
    [javac]     @TargetApi(Build.VERSION_CODES.KITKAT)
    [javac]                                   ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaUriHelper.java:49: error: cannot find symbol
    [javac]     @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
    [javac]                                   ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH_MR1
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java:38: error: cannot find symbol
    [javac]     @JavascriptInterface
    [javac]      ^
    [javac]   symbol:   class JavascriptInterface
    [javac]   location: class ExposedJsApi
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java:43: error: cannot find symbol
    [javac]     @JavascriptInterface
    [javac]      ^
    [javac]   symbol:   class JavascriptInterface
    [javac]   location: class ExposedJsApi
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java:48: error: cannot find symbol
    [javac]     @JavascriptInterface
    [javac]      ^
    [javac]   symbol:   class JavascriptInterface
    [javac]   location: class ExposedJsApi
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:34: error: cannot find symbol
    [javac] @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    [javac]                               ^
    [javac]   symbol:   variable HONEYCOMB
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/com/squareup/okhttp/internal/http/HttpsURLConnectionImpl.java:347: error: method does not override or implement a method from a supertype
    [javac]   @Override public void setFixedLengthStreamingMode(long contentLength) {
    [javac]   ^
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:135: error: no suitable constructor found for WebView(Context,AttributeSet,int,boolean)
    [javac]         super(context, attrs, defStyle, privateBrowsing);
    [javac]         ^
    [javac]     constructor WebView.WebView(Context,AttributeSet,int) is not applicable
    [javac]       (actual and formal argument lists differ in length)
    [javac]     constructor WebView.WebView(Context,AttributeSet) is not applicable
    [javac]       (actual and formal argument lists differ in length)
    [javac]     constructor WebView.WebView(Context) is not applicable
    [javac]       (actual and formal argument lists differ in length)
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:197: error: cannot find symbol
    [javac]             if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB &&
    [javac]                                                                                 ^
    [javac]   symbol:   variable HONEYCOMB
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:218: error: cannot find symbol
    [javac]         if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
    [javac]                                                                              ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH_MR1
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:230: error: cannot find symbol
    [javac]             android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
    [javac]                                                                               ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:269: error: cannot find symbol
    [javac]             WebView.setWebContentsDebuggingEnabled(true);
    [javac]                    ^
    [javac]   symbol:   method setWebContentsDebuggingEnabled(boolean)
    [javac]   location: class WebView
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:281: error: cannot find symbol
    [javac]         if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    [javac]                                                                              ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:298: error: cannot find symbol
    [javac]         if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
    [javac]                                                         ^
    [javac]   symbol:   variable JELLY_BEAN_MR1
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:830: error: cannot find symbol
    [javac]             settings.setAllowUniversalAccessFromFileURLs(true);
    [javac]                     ^
    [javac]   symbol:   method setAllowUniversalAccessFromFileURLs(boolean)
    [javac]   location: variable settings of type WebSettings
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaUriHelper.java:74: error: cannot find symbol
    [javac]                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
    [javac]                                                                 ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH_MR1
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaUriHelper.java:75: error: cannot find symbol
    [javac]                     intent.setSelector(null);
    [javac]                           ^
    [javac]   symbol:   method setSelector(<null>)
    [javac]   location: variable intent of type Intent
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/CordovaActivity.java:345: error: cannot find symbol
    [javac]             appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    [javac]                                           ^
    [javac]   symbol:   variable OVER_SCROLL_NEVER
    [javac]   location: class View
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:74: error: cannot find symbol
    [javac]         this.aperture = inFile.getAttribute(ExifInterface.TAG_APERTURE);
    [javac]                                                          ^
    [javac]   symbol:   variable TAG_APERTURE
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:76: error: cannot find symbol
    [javac]         this.exposureTime = inFile.getAttribute(ExifInterface.TAG_EXPOSURE_TIME);
    [javac]                                                              ^
    [javac]   symbol:   variable TAG_EXPOSURE_TIME
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:79: error: cannot find symbol
    [javac]         this.gpsAltitude = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE);
    [javac]                                                             ^
    [javac]   symbol:   variable TAG_GPS_ALTITUDE
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:80: error: cannot find symbol
    [javac]         this.gpsAltitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF);
    [javac]                                                                ^
    [javac]   symbol:   variable TAG_GPS_ALTITUDE_REF
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:88: error: cannot find symbol
    [javac]         this.iso = inFile.getAttribute(ExifInterface.TAG_ISO);
    [javac]                                                     ^
    [javac]   symbol:   variable TAG_ISO
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:107: error: cannot find symbol
    [javac]             this.outFile.setAttribute(ExifInterface.TAG_APERTURE, this.aperture);
    [javac]                                                    ^
    [javac]   symbol:   variable TAG_APERTURE
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:113: error: cannot find symbol
    [javac]             this.outFile.setAttribute(ExifInterface.TAG_EXPOSURE_TIME, this.exposureTime);
    [javac]                                                    ^
    [javac]   symbol:   variable TAG_EXPOSURE_TIME
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:122: error: cannot find symbol
    [javac]             this.outFile.setAttribute(ExifInterface.TAG_GPS_ALTITUDE, this.gpsAltitude);
    [javac]                                                    ^
    [javac]   symbol:   variable TAG_GPS_ALTITUDE
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:125: error: cannot find symbol
    [javac]             this.outFile.setAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF, this.gpsAltitudeRef);
    [javac]                                                    ^
    [javac]   symbol:   variable TAG_GPS_ALTITUDE_REF
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/ExifHelper.java:149: error: cannot find symbol
    [javac]             this.outFile.setAttribute(ExifInterface.TAG_ISO, this.iso);
    [javac]                                                    ^
    [javac]   symbol:   variable TAG_ISO
    [javac]   location: class ExifInterface
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:56: error: cannot find symbol
    [javac]                 return new WebResourceResponse("text/plain", "UTF-8", null);
    [javac]                            ^
    [javac]   symbol:   class WebResourceResponse
    [javac]   location: class IceCreamCordovaWebViewClient
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:66: error: cannot find symbol
    [javac]                 return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
    [javac]                            ^
    [javac]   symbol:   class WebResourceResponse
    [javac]   location: class IceCreamCordovaWebViewClient
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:75: error: cannot find symbol
    [javac]             return new WebResourceResponse("text/plain", "UTF-8", null);
    [javac]                        ^
    [javac]   symbol:   class WebResourceResponse
    [javac]   location: class IceCreamCordovaWebViewClient
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:48: error: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:85: error: cannot find symbol
    [javac]         return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && "content".equals(uri.getScheme());
    [javac]                                                                                  ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:101: error: cannot find symbol
    [javac]             case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH:
    [javac]                                                ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH
    [javac]   location: class VERSION_CODES
    [javac] /Path/local/hello/platforms/android/CordovaLib/src/org/apache/cordova/IceCreamCordovaWebViewClient.java:102: error: cannot find symbol
    [javac]             case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
    [javac]                                                ^
    [javac]   symbol:   variable ICE_CREAM_SANDWICH_MR1
    [javac]   location: class VERSION_CODES
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 38 errors

BUILD FAILED
/ARQUIVOS/AndroidSDK/Mac/tools/ant/build.xml:601: The following error occurred while executing this line:
/ARQUIVOS/AndroidSDK/Mac/tools/ant/build.xml:720: The following error occurred while executing this line:
/ARQUIVOS/AndroidSDK/Mac/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 2 seconds

/Path/local/hello/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/Path/local/hello/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Path/local/hello/platforms/android/cordova/run: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

1 个答案:

答案 0 :(得分:2)

您正在使用

[gettarget] API level:        8

但是,根据documentation, JavascriptInterface,自API级别17起可用。尝试增加项目中的目标API级别以解决问题。

通常您可以在AndroidManifest.xml文件中定义API级别。例如,在这样的行中:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />

根据您的需要进行调整,但至少使用SdkVersion 17。

此外,安装所需的Android SDK版本。您可以在Android SDK Manager中执行此操作。它可以通过从控制台发出命令android来启动。