Error compiling the ionic on android

Hello guys,
Do you have any idea what can be?

C:\wamp\www\git\sobradaobra.app\SobraDaObra [backendless +0 ~13 -0]> ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\wamp\www\git\sobradaobra.app\SobraDaObra\hooks\after_prepare\010_
add_platform_class.js C:\wamp\www\git\sobradaobra.app\SobraDaObra
add to body class: platform-android
Running command: cmd "/s /c "C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\cordova\build.bat""
ANDROID_HOME=d:\android-sdk-win
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
Running: C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\gradlew cdvBuildDebug -b C:\wamp\www\git\sobradao
bra.app\SobraDaObra\platforms\android\build.gradle -Dorg.gradle.daemon=true
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJava UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:packageDebugJar UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:packageDebugJniLibs UP-TO-DATE
:CordovaLib:packageDebugLocalJar UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugAssets'.
> java.lang.NullPointerException (no error message)

* 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.324 secs

C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s /c "C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\gradlew cd
vBuildDebug -b C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (C:\Users\Raul\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordov
a\superspawn.js:134: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)
1 Like

Try to run the failing command manually to see if yo get more info.

cmd /s /c "C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\gradlew cd
vBuildDebug -b C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\build.gradle -Dorg.gradle.daemon=true"

Have a look at local.properties file in platforms/android folder.

We had the same issue, and it was a bundle path configuring problem.

You should take a look at your enviroment variables (path to android sdks).

The command line works, but when I give a build it continues with the same error.

C:> cmd /s /c "C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\gradlew

cd
vBuildDebug -b C:\wamp\www\git\sobradaobra.app\SobraDaObra\platforms\android\build.gradle -Dorg.gradle.daemon=true"

:help

Welcome to Gradle 2.2.1.

To run a build, run gradlew …

To see a list of available tasks, run gradlew tasks

To see a list of command-line options, run gradlew --help

BUILD SUCCESSFUL

Total time: 2.261 secs

I had already checked and are all right. Also compiled other app and it worked without any issue.

My colleague had the same problem. He downloaded the project from git, he set different path for android sdks, then when he tried to compile it, its just didn’t worked, he was able to run another project although, just like you. Then he decided copy the sdks into the same place we had, then the build was success.

+check the sdk versions

Thank you for your help.

This solved:

ionic platform remove android
ionic platform add android
7 Likes

raulclaudino’s solution worked for me as well. thanks! :grinning:

I just updated packages:

npm update

Hope this works for someone

thank you now it is working

thank you this work for me:grinning: