Processing node_modules failed. Error: Command gradlew.bat failed with exit code 1


#1

I’m trying to build an empty project I created via “tns create project --ng” on a new computer. I installed NS with the new installer, added android as my platform, and get this error with tns run android andtns build android

From my research, I believe that the issue has something to do with a missing path variable or a firewall. As of now, everything I’ve tried as yet to yield results :-/

C:\Users\JXB4618\Documents\HelloWorld>tns build android
Executing before-prepare hook from C:\Users\JXB4618\Documents\HelloWorld\hooks\before-prepare\nativescript-dev-android-snapshot.js
Preparing project...
[Fatal Error] apache-4.pom:2:1: Content is not allowed in prolog.
[Fatal Error] apache-4.pom:2:1: Content is not allowed in prolog.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'HelloWorld'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve commons-logging:commons-logging:1.1.1.
     Required by:
         project : > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > org.apache.httpcomponents:httpclient:4.1.1
         project : > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > org.apache.httpcomponents:httpmime:4.1
      > Could not resolve commons-logging:commons-logging:1.1.1.
         > Could not parse POM https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
            > Could not resolve org.apache.commons:commons-parent:5.
               > Could not resolve org.apache.commons:commons-parent:5.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not parse POM https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom
                              > Content is not allowed in prolog.
   > Could not resolve commons-codec:commons-codec:1.4.
     Required by:
         project : > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdklib:25.2.3 > org.apache.httpcomponents:httpclient:4.1.1
      > Could not resolve commons-codec:commons-codec:1.4.
         > Could not parse POM https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
            > Could not resolve org.apache.commons:commons-parent:11.
               > Could not resolve org.apache.commons:commons-parent:11.
                  > Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
                     > Could not resolve org.apache:apache:4.
                        > Could not resolve org.apache:apache:4.
                           > Could not parse POM https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom
                              > Content is not allowed in prolog.

* 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.029 secs
Processing node_modules failed. Error: Command gradlew.bat failed with exit code 1

#2

@Quinn looks like some kind of incompatibility with the android build tools, though I have not experienced nor seen the error before so it’s a guess.

What’s the version of Android Build Tools that you have installed? You should have at the very least 25.0.2


#3

I have all the android build tools Rev. 19.1 - 25.2.5 installed.


#4

@Quinn is it an option to remove the latest tools up to 25.0.2, see if that doesn’t fix the problem?


#5

@Pete.K I deleted the old version but still running into the same issue. I’m on an enterprise version of windows so not sure if that might have something to do with the issue.


#6

I faced similar issue. I am not sure your problem have same solution. Nevertheless, I assume you are working behind corporate proxy then you need to set system proxy settings also set proxy for gradle .


#7

The error I got when simulating a proxy setting was 407 unauthorized. You could try following the process described in https://github.com/NativeScript/nativescript-cli/issues/2816#issuecomment-302431026 to setup the gradle proxy settings to build on Android if you are operating behind a corporate proxy.


#8

I believe this issue has no solution, I tried everything there is to fix this problem with a lot of searching the net for solutions for a week with at least 3 hours every single day and I still keep getting the same error “command gradlew.bat failed with exit code 1”.


#9

You might be having a different error than the one cited here. command gradlew.bat failed with exit code 1 is just a generic error code thrown when the build fails, while the actual cause for that can happen anytime during the build. You could share the build logs with us all, so we can try to see what’s wrong. Try running a build with logging enabled, pipe into a file and upload.

tns run android --log trace > build-log.txt


#10

Ok, thanks for clarifying things Pete, I just got frustrated. So I did that command and what I got is a huge build-log.txt file, here it is:


#11

@samwil The problem for me had to do with an issue in my proxy settings preventing me from pulling dependencys behind​ a corporate firewall. I ended up doing a soft reset of windows and that fixed the problem for me.


#12

First thing I noticed - you are building the project under C:/Windows/System32 - please don’t, that’s where most of your Windows lives, and you don’t want to be polluting that. a directory for all your projects under C:/work or your user directory will work just fine!

Second - I noticed that the build is using appt tools from build-tools 23.0.1 (QueuedCruncher is using C:\Users\samwil\AppData\Local\Android\sdk1\build-tools\23.0.1\aapt.exe) - consider downloading 25.0.2, as that is the recommended, and right now - the only build version you should be needing if building with NativeScript.

Third - the actual build error is :mergeF0DebugResources FAILED, it could probably have become clear by the normal build log. Judging by the rest of the log preceding the error, I think Gradle (the build system used for building android apps)'s resource cruncher fails midway. And that looks familiar to an error that I identified a few weeks ago - https://github.com/NativeScript/android-runtime/issues/768#issuecomment-304208247 . If updating the build-tools doesn’t help, disabling the cruncher might do.

Good luck!


#13

@Pete.K sorry I didn’t respond for a few days I was busy, thank you so much that fixed it for me! I am new to mobile apps and I almost gave up on it, all I did was change your first and second notes and that did the trick, I didn’t even get to the issue of :mergeF0DebugResources. Thanks again!!! :smile: