1. 2018年4月运行以前的cordova项目出错,新建项目也不行
node v6.10.4下,将cordova卸载,然后重装6.3.1
$ cnpm uninstall -g cordova
$ cpnm i -g cordova@6.3.1
$ cordova create xxx
2. 构建项目出错
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:processDebugResources'.
> java.io.IOException: Cannot run program "/home/johnny/dev/android-sdk-linux/build-tools/22.0.1/aapt": error=2, 没有那个文件或目录
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
cordova需要32位包,但环境为64位ubuntu,安装必要lib
sudo apt-get install lib32stdc++6 lib32z1
3. 构建项目出错
windows和ubuntu同样错误,但是windows gitbash中错误信息乱码,用linux build看到错误如下:
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:25: 错误: 找不到符号
import android.webkit.ClientCertRequest;
^
符号: 类 ClientCertRequest
位置: 程序包 android.webkit
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:32: 错误: 找不到符号
private final ClientCertRequest request;
^
符号: 类 ClientCertRequest
位置: 类 CordovaClientCertRequest
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:34: 错误: 找不到符号
public CordovaClientCertRequest(ClientCertRequest request) {
^
符号: 类 ClientCertRequest
位置: 类 CordovaClientCertRequest
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:29: 错误: 找不到符号
import android.webkit.ClientCertRequest;
^
符号: 类 ClientCertRequest
位置: 程序包 android.webkit
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:116: 错误: 找不到符号
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
^
符号: 类 ClientCertRequest
位置: 类 SystemWebViewClient
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:40: 错误: 找不到符号
import android.webkit.PermissionRequest;
^
符号: 类 PermissionRequest
位置: 程序包 android.webkit
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:253: 错误: 找不到符号
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
^
符号: 类 FileChooserParams
位置: 类 WebChromeClient
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:273: 错误: 找不到符号
public void onPermissionRequest(final PermissionRequest request) {
^
符号: 类 PermissionRequest
位置: 类 SystemWebChromeClient
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:251: 错误: 找不到符号
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
^
符号: 变量 LOLLIPOP
位置: 类 VERSION_CODES
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:271: 错误: 找不到符号
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
^
符号: 变量 LOLLIPOP
位置: 类 VERSION_CODES
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:114: 错误: 方法不会覆盖或实现超类型的方法
@Override
^
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:37: 错误: 找不到符号
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
符号: 变量 LOLLIPOP
位置: 类 VERSION_CODES
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:38: 错误: 找不到符号
cookieManager.setAcceptThirdPartyCookies(webView, true);
^
符号: 方法 setAcceptThirdPartyCookies(WebView,boolean)
位置: 类型为CookieManager的变量 cookieManager
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:59: 错误: 找不到符号
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
符号: 变量 LOLLIPOP
位置: 类 VERSION_CODES
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java:60: 错误: 找不到符号
cookieManager.flush();
^
符号: 方法 flush()
位置: 类型为CookieManager的变量 cookieManager
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:252: 错误: 方法不会覆盖或实现超类型的方法
@Override
^
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:259: 错误: 找不到符号
Uri[] result = WebChromeClient.FileChooserParams.parseResult(resultCode, intent);
^
符号: 变量 FileChooserParams
位置: 类 WebChromeClient
/home/johnny/dev/wk/testapp/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebChromeClient.java:272: 错误: 方法不会覆盖或实现超类型的方法
@Override
^
注: 某些输入文件使用或覆盖了已过时的 API。
3. IOS 编译错误
$ cordova build ios
(node:669) UnhandledPromiseRejectionWarning: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
(node:669) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:669) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
百度后说因为安装了多个xcode,需要指定一个
$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
4. IOS执行npm install的错误
Access permission xxx/node_modules/xxx
重启mac