我正在尝试使用Cordova构建一个Android应用程序。我正在使用Cordova 5.2.0,我想为Android 4.3.1构建,所以在我的project.properties中插入了:
target=android-18
不幸的是,当我启动时
sudo cordova build android
我在“CordovaLib:compileDebugJava”任务中获得错误。
这是完整的错误报告:
Mac-di-Luca:studioapp4 XXXXXXX$ sudo cordova build android
Running command: /Users/XXXXXXX/Desktop/studioapp4/platforms/android/cordova/build
ANDROID_HOME=/Users/XXXXXXX/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/XXXXXXX/Desktop/studioapp4/platforms/android/gradlew cdvBuildDebug -b /Users/XXXXXXX/Desktop/studioapp4/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild
:compileDebugNdk
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugBuildConfig
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:compileDebugJava
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:25: cannot find symbol
symbol : class ClientCertRequest
location: package android.webkit
import android.webkit.ClientCertRequest;
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:32: cannot find symbol
symbol : class ClientCertRequest
location: class org.apache.cordova.CordovaClientCertRequest
private final ClientCertRequest request;
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:34: cannot find symbol
symbol : class ClientCertRequest
location: class org.apache.cordova.CordovaClientCertRequest
public CordovaClientCertRequest(ClientCertRequest request) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:40: cannot find symbol
symbol : class PermissionRequest
location: package android.webkit
import android.webkit.PermissionRequest;
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:253: cannot find symbol
symbol : class FileChooserParams
location: class android.webkit.WebChromeClient
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:273: cannot find symbol
symbol : class PermissionRequest
location: class org.apache.cordova.engine.SystemWebChromeClient
public void onPermissionRequest(final PermissionRequest request) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:29: cannot find symbol
symbol : class ClientCertRequest
location: package android.webkit
import android.webkit.ClientCertRequest;
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:116: cannot find symbol
symbol : class ClientCertRequest
location: class org.apache.cordova.engine.SystemWebViewClient
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:251: cannot find symbol
symbol : variable LOLLIPOP
location: class android.os.Build.VERSION_CODES
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:271: cannot find symbol
symbol : variable LOLLIPOP
location: class android.os.Build.VERSION_CODES
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewEngine.java:240: cannot find symbol
symbol : variable KITKAT
location: class android.os.Build.VERSION_CODES
@TargetApi(Build.VERSION_CODES.KITKAT)
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/CordovaActivity.java:123: cannot find symbol
symbol : variable KITKAT
location: class android.os.Build.VERSION_CODES
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/CordovaActivity.java:327: cannot find symbol
symbol : variable SYSTEM_UI_FLAG_IMMERSIVE_STICKY
location: class android.view.View
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:37: cannot find symbol
symbol : variable LOLLIPOP
location: class android.os.Build.VERSION_CODES
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:38: cannot find symbol
symbol : method setAcceptThirdPartyCookies(android.webkit.WebView,boolean)
location: class android.webkit.CookieManager
cookieManager.setAcceptThirdPartyCookies(webView, true);
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:59: cannot find symbol
symbol : variable LOLLIPOP
location: class android.os.Build.VERSION_CODES
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:60: cannot find symbol
symbol : method flush()
location: class android.webkit.CookieManager
cookieManager.flush();
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:259: cannot find symbol
symbol : variable FileChooserParams
location: class android.webkit.WebChromeClient
Uri[] result = WebChromeClient.FileChooserParams.parseResult(resultCode, intent);
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:252: method does not override or implement a method from a supertype
@Override
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:272: method does not override or implement a method from a supertype
@Override
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewEngine.java:192: cannot find symbol
symbol : variable KITKAT
location: class android.os.Build.VERSION_CODES
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewEngine.java:243: cannot find symbol
symbol : method setWebContentsDebuggingEnabled(boolean)
location: class android.webkit.WebView
WebView.setWebContentsDebuggingEnabled(true);
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:114: method does not override or implement a method from a supertype
@Override
^
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:352: cannot find symbol
symbol : variable KITKAT
location: class android.os.Build.VERSION_CODES
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && "content".equals(uri.getScheme());
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
24 errors
:CordovaLib:compileDebugJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.856 secs
/Users/XXXXXXX/Desktop/studioapp4/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/XXXXXXX/Desktop/studioapp4/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/XXXXXXX/Desktop/studioapp4/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/XXXXXXX/Desktop/studioapp4/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/XXXXXXX/Desktop/studioapp4/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
感谢所有人!
答案 0 :(得分:1)
您遇到此错误,因为您为此版本的Cordova设置了太低的Android目标。
E.g。 android.webkit.ClientCertRequest类仅在API level 21
中添加如果您查看latest Cordova documentation,就会发现 Android 5.1.1(API 22)平台SDK 是必需的。
要编译,您必须安装并设置为更新的Android平台SDK。