1. <legend id="z1ta0"></legend>

          <label id="z1ta0"></label>

          <label id="z1ta0"></label>

            <big id="z1ta0"></big>

            Cordova一些問題

            小編:管理員 231閱讀 2022.09.13

            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

            關聯標簽: