簡體   English   中英

使用Cordova的Ionic 3構建失敗:cordova \\ node_modules \\ cordova-common \\ src \\ superspawn.js:169:23

[英]Ionic 3 BUILD FAILED with Cordova: cordova\node_modules\cordova-common\src\superspawn.js:169:23

在帶有Cordova的Ionic 3中,當我給出命令時:

ionic cordova run android --device

我已經在系統環境中安裝並設置了路徑

JDK SDK節點js

我在互聯網上進行了大量研究,但無法解決。 我做錯了什么?

甚至格式化已經格式化的計算機。 我不知道該怎么辦。 來自其他論壇的帶有“應該”相同錯誤的消息均未解決。

它給了我以下錯誤:

`E:\NAB\ionic\new\myApp>ionic cordova run android
Running app-scripts build: --platform android --target cordova
[12:54:42]  build dev started ...
[12:54:43]  clean started ...
[12:54:43]  clean finished in 16 ms
[12:54:43]  copy started ...
[12:54:44]  deeplinks started ...
[12:54:44]  deeplinks finished in 203 ms
[12:54:44]  transpile started ...
[12:54:58]  transpile finished in 14.50 s
[12:54:58]  preprocess started ...
[12:54:58]  preprocess finished in less than 1 ms
[12:54:59]  webpack started ...
[12:54:59]  copy finished in 15.94 s
[12:55:32]  webpack finished in 33.82 s
[12:55:32]  sass started ...
[12:55:38]  sass finished in 5.26 s
[12:55:38]  postprocess started ...
[12:55:38]  postprocess finished in 78 ms
[12:55:38]  lint started ...
[12:55:38]  build dev finished in 55.31 s
> cordova run android
Android Studio project detected

ANDROID_HOME=C:\Users\Sohail Akbar\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find gradle-core.jar (com.android.tools.build:gradle-core:3.0.0).

     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle-core/3.0.0/g
radle-core-3.0.0.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
[12:55:47]  lint finished in 9.31 s
(node:2132) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with ex
it code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find gradle-core.jar (com.android.tools.build:gradle-core:3.0.0).

     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle-core/3.0.0/g
radle-core-3.0.0.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
    at ChildProcess.whenDone (E:\NAB\ionic\new\myApp\platforms\android\cordova\n
ode_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:2132) 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:2132) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.`

提前致謝

對不起,我的英語不好,我會盡力以簡單的方式提出答案。

我只花了兩天兩夜的時間來解決同一問題,最后找到了一個。

主要問題在於Android-NDK。

Ionic框架正在Android SDK的ndk-bundle文件夾中尋找mips64el-linux-android軟件包。

如果訪問Android-SDK文件夾,則將找到一個名為ndk-bundle的文件夾,在該文件夾中,將打開名為toolchains的文件夾。您會看到該toolchains不包含軟件包mips64el-linux-android

您必須手動下載。 您可以在此處下載最新版本的Android-NDK ,但是很遺憾,該最新版本不包含我們所需的軟件包。

在此頁面的底部,您將找到一個鏈接,用於下載較舊版本的Android-NDK ,然后Android NDK, Revision 14b (March 2017)該鏈接並下載Android NDK, Revision 14b (March 2017) 那是Ionic尋找的NDK版本。 現在轉到您的Android-SDK路徑,然后轉到NDK-Bundle ,然后從該文件夾中刪除所有內容。 並將下載的文件解壓縮到NDK-Bundle folder ,您將看到包mips64el-linux-android

現在一切都很好。 希望它會起作用。

以下是我在上安裝經驗總結。 特別請參閱關於錯誤的部分。 只需按照說明創建虛擬文件夾和子文件夾即可。

科爾多瓦希望看到C:\\Users\\myusernamehere\\AppData\\Local\\Android\\Sdk\\ndk-bundle\\toolchains\\mips64el-linux-android-4.9\\prebuilt\\windows-x86_64\\bin\\mips64el-linux-android-strip但不需要(在我的情況下),如果不存在,將拋出錯誤。

Ionic Cordova安裝經驗。

• Re- install Java JDK 8 to the latest update.
• Add ANDROID_SDK_ROOT variable to point to existing installation of Android Studio SDK
• Add Java JDK\bin to the environment PATH variable on user and system
• Download Gradle 5.2 and create folder C:\Gradle and extract the contents inside. Your 
The path should look like this  

C:\\Gradle\\gradle-5.2\\bin\\gradle.bat

  • "C:\\Gradle\\gradle-5.2\\bin"到系統上的PATH變量

    從命令行執行以下操作。

  1. export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
  2. export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
  3. export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
  4. export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
• Using a previously installed edition of Android Studio go to Tools => SDK Tools 
And check the NDK checkbox for download, click apply and ok.
• In the project terminal - Enter 

離子科爾多瓦准備android

建立科爾多瓦。
如果有錯誤,請刪除platforms\\android項目目錄並重建。
如果有Gradle錯誤,則尋找NDK "mips64el-linux-android-version"

Do the following ..  

• Open the NDK bundle\toolchains folder within Android SDK eg C:\Users\Shay\AppData\Local\Android\sdk\ndk-bundle\toolchains
• And using command line create a folder "mips64el-linux-android-4.9" ( same version number (4.9) as other folders) inside create folder "prebuilt" .. then folder "windows-x86_64" and inside place and empty text file for contents. 
The created path should look like .. "C:\Users\Shay\AppData\Local\Android\sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\dummy file"  is not required by Cordova but is expected to be in its path .. otherwise it will throw an error and fail to build.

或者,下載舊版本,例如https://developer.android.com/ndk/downloads/older_releases/android-ndk-r16b-windows-x86_64.zip,然后將所需的文件夾提取到新的文件夾中,該文件夾與以上。

• Finally, once again enter 

離子科爾多瓦准備android

建立科爾多瓦

The Ionic build order (as I observed it) is a follows ..

1. It looks for all the relevant Java and Android SDK paths .. 
2. Then uses Gradle as the build system .. 
3. Check for NDK bundle ..
4. Build project

以上花了我兩天時間才弄清楚。 希望它能幫助您,並且省去您的頭痛。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM