简体   繁体   中英

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

In Ionic 3 with Cordova when I give the command:

ionic cordova run android --device

i have already installed and set the path in system environment

JDK SDK Node js

I have researched a lot on the internet and I can not solve it. What can I be doing wrong?

Even formatting the computer already formatted. I do not know what to do. Neither messages from other forums with the "supposed" same error, did not work out.

It gives me the following errors:

`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.`

thanks in advance

Sorry for my bad English, I will try my best to present the answer in easy way.

I just spend my two days and nights on solving the same issue and finally I found one.

The main problem is with the Android-NDK.

Ionic framework is looking for mips64el-linux-android package in the ndk-bundle folder of Android SDK.

If You visit Your Android-SDK folder, You will find a folder with name ndk-bundle , inside this open the folder name toolchains You will see that toolchains doesn't contains the package mips64el-linux-android .

You have to download it manually. You can download the latest version of Android-NDK here , but unfortunately this latest version doesn't contain the package we need.

At the bottom of this page You will find a link to download the older versions of Android-NDK , follow that link and download Android NDK, Revision 14b (March 2017) . That's the NDK version Ionic looking for. Now go to Your Android-SDK path, then NDK-Bundle and delete everything from that folder. And extract the downloaded file in NDK-Bundle folder , You will see the package mips64el-linux-android .

Everything is good to go now. Hope so it will work.

Below is a summation of my experience installing on . See in particular the section on error. Just follow along and create the dummy folder and subfolders as explained.

Cordova expects to see the path to C:\\Users\\myusernamehere\\AppData\\Local\\Android\\Sdk\\ndk-bundle\\toolchains\\mips64el-linux-android-4.9\\prebuilt\\windows-x86_64\\bin\\mips64el-linux-android-strip but does not require it (in my case) and will throw an error if absent.

Ionic Cordova Installation experience.

• 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

  • Add "C:\\Gradle\\gradle-5.2\\bin" to PATH variable on System

    From the command line do the following ..

  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 

ionic cordova prepare android

to build Cordova.
If there are errors delete the platforms\\android project directory and rebuild.
If there is a Gradle error looking for 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.

Alternatively, download an older build such as https://developer.android.com/ndk/downloads/older_releases/android-ndk-r16b-windows-x86_64.zip and extract the required folder to the new folder in the same location as above.

• Finally, once again enter 

ionic cordova prepare android

to build Cordova

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

The above took me two days to figure out. Hope it helps and saves you the headache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM