Apollo-android: Build failure - \node-v6.7.0-win-x64\node.exe'' finished with non-zero exit value 1

Created on 3 Aug 2017  路  27Comments  路  Source: apollographql/apollo-android

I have installed Node Js version v6.11.0. But I'm getting the following error. Please help me on this.

Information:Gradle tasks [:apollo-android-support:generateDebugSources, :apollo-android-support:mockableAndroidJar, :apollo-android-support:prepareDebugUnitTestDependencies, :apollo-android-support:generateDebugAndroidTestSources, :apollo-espresso-support:generateDebugSources, :apollo-espresso-support:generateDebugAndroidTestSources, :apollo-espresso-support:mockableAndroidJar, :apollo-espresso-support:prepareDebugUnitTestDependencies, :apollo-integration:generateDebugSources, :apollo-integration:mockableAndroidJar, :apollo-integration:prepareDebugUnitTestDependencies, :apollo-integration:generateDebugAndroidTestSources, :apollo-sample:generateDebugSources, :apollo-sample:mockableAndroidJar, :apollo-sample:prepareDebugUnitTestDependencies, :apollo-sample:generateDebugAndroidTestSources]
Error:Execution failed for task ':apollo-integration:generateDebugApolloIR'.

Process 'command '\apollo-android-master\apollo-integration.gradle\nodejs\node-v6.7.0-win-x64\node.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 3.551 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

gradle-plugin

Most helpful comment

Apollo 0.4.4
Ubuntu 17.10

Error:Execution failed for task ':app:installApolloCodegen'. Process 'command './app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node'' finished with non-zero exit value 243

Same issue here as well, even with the sample project, only difference is instead of getting exit value of 1 I get exit value of 243

Update!! Exit Value 243 Solved

So after checking the log file for:

./app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node

I saw that the error I was getting was due to the .npm directory in my home folder belonging to root and not my current user which meant I wouldn't be able to run any npm commands without using sudo.

Solution (Exit Value 243):
Change ownership of you .npm folder so that the current user doesn't have to run npm commands as sudo/root

sudo chown -R $(whoami) ~/.npm

_Credits: https://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo_

Exit Value 1 (Error:Validation of GraphQL query document failed)

My specific issue for:

Error:Execution failed for task ':app:generateDebugApolloIR'. Process 'command ./app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node'' finished with non-zero exit value 1

Appears to be caused by using similar fragment names in my separate .graphql files, thus changing the name to assure they are different fixed my issue

All 27 comments

I'm having the exact same issue tried around with different node versions and tried different order of gradle tasks also. Happens to me on 'com.apollographql.apollo:gradle-plugin:0.4.0' and on 'com.apollographql.apollo:gradle-plugin:0.4.1-SNAPSHOT'. Any Idea how this could be solved?

Can you try running with --info --stacktrace and post the output?

Apollo does not support anonymous operations
https://github.com/apollographql/apollo-codegen/issues/184

Successfully started process 'command '/Users/xxx/Documents/FirstGraphQL/app/.gradle/nodejs/node-v6.7.0-darwin-x64/bin/node''
.../graphql/zzz/firstgraphql/GithuntFeedQuery.graphql: Apollo does not support anonymous operations
error: Validation of GraphQL query document failed
:app:generateDebugApolloIR FAILED
:app:generateDebugApolloIR (Thread[Daemon worker,5,main]) completed. Took 0.579 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateDebugApolloIR'.
> Process 'command '/Users/xxx/Documents/FirstGraphQL/app/.gradle/nodejs/node-v6.7.0-darwin-x64/bin/node'' finished with non-zero exit value 1

I had this issue with Apollo 0.4.1 and Kotlin 1.1.51 and the only thing that worked was downgrading Kotlin to 1.1.50.

I'm also getting the same error. I double checked the schema.json and .graphql query file.

Error:org.gradle.process.internal.ExecException: Process 'command
'......app/.gradle/nodejs/node-v6.7.0-darwin-x64/bin/node'' finished with non-zero exit value 1

I'm using apollo v0.4.4 and kotlin v1.2.20. Can anyone tell me why Apollo is throwing this error during code generation?

Ok, I have the exact same problem but I could build in command line but not through Android Studio. Running with --info in AS's terminal I got this:

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\vince\dev\app\build\apollo-codegen\node_modules\apollo-codegen' -> 'C:\Users\vince\dev\app\build\apollo-codegen\node_modules\.apollo-codegen.DELETE'
npm ERR!     at Error (native) parent: 'apollo-android' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

So for me it seems to be a permissions problem

I'm getting this error with Apollo v0.4.4 but the code-gen works fine with v0.4.3.

Error:org.gradle.process.internal.ExecException: Process 'command
'......app/.gradle/nodejs/node-v6.7.0-darwin-x64/bin/node'' finished with non-zero exit value 1

Apollo 0.4.4
Ubuntu 17.10

Error:Execution failed for task ':app:installApolloCodegen'. Process 'command './app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node'' finished with non-zero exit value 243

Same issue here as well, even with the sample project, only difference is instead of getting exit value of 1 I get exit value of 243

Update!! Exit Value 243 Solved

So after checking the log file for:

./app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node

I saw that the error I was getting was due to the .npm directory in my home folder belonging to root and not my current user which meant I wouldn't be able to run any npm commands without using sudo.

Solution (Exit Value 243):
Change ownership of you .npm folder so that the current user doesn't have to run npm commands as sudo/root

sudo chown -R $(whoami) ~/.npm

_Credits: https://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo_

Exit Value 1 (Error:Validation of GraphQL query document failed)

My specific issue for:

Error:Execution failed for task ':app:generateDebugApolloIR'. Process 'command ./app/.gradle/nodejs/node-v6.7.0-linux-x64/bin/node'' finished with non-zero exit value 1

Appears to be caused by using similar fragment names in my separate .graphql files, thus changing the name to assure they are different fixed my issue

Pay attention that every query has a name...

I had the same issue, and was able to resolve it by naming my query as mentioned above.

I ran into the same problem today after trying to update my schema.json, and double checked my new queries. There is nothing wrong with them. Could there be another reason for this problem?

New information
After comparing the new schema.json with the old one, I noticed that the format of the generated schema has changed in the new apollo-cli, and it has resulted in this error.
The old format was like this

{
  "data": {
    "__schema": {
      "queryType": {
        "name": "Query"
      },
      "mutationType": {
        "name": "Mutation"
      },
      "subscriptionType": null,
      ....

While the new format is like this

{
  "queryType": {
    "name": "Query"
  },
  "mutationType": {
    "name": "Mutation"
  },
  "subscriptionType": null,

The problem was solved by using the old version of appollo-codegen cli.

@hshahdoost
Same here man. A variable was changed on the graphql server and I needed to update my query. Therefor also needed to update the schema.json and the shitshow started.

How did you downgrade the apollo-codegen cli ?

@hopstad first make sure you are not using the apollo cli (the old apollo-codegen has been deprecated and been replaced by this new command). the generated schema by apollo cli is not readable by apollo android
Then go to this url to see the available versions of apollo-codegen.

And finally uninstall your current apollo-codegen and install it in the following format

npm install [email protected]

PS: by the time I faced this error, Apollo android could not read the schema generated by apollo cli , It might not be like this in the future versions so the best practice would be to first update your library to the latest version and then (if it could not read the schema) try using apollo-codegen command

@hshahdoost
Thanks mate! You saved my brain from exploding.

Solved by removing apollo and installing the new one. Then using new command for downloading schema : apollo schema:download --endpoint=https://something.com

@hshahdoost

Nevermind.. Still not working. I thought it was, but was wrong. What I did was uninstall apollo and tried the new one (apollo schema:download). The error was now of a different type and said the following:

GraphQL schema file should contain a valid GraphQL introspection query result

Tried to uninstall again and download a old apollo version (0.20.2) and did the same old "apollo-codegen" and them I'm back to the same error as before:

error: Validation of GraphQL query document failed

EDIT
Finally fixed. Totally removed everything. npm, apollo etc. Deleted .grade file in Android Studio. Reinstalled everything (apollo-codegen not apollo) and it works now.

@hopstad I kind of got surprised because in your mention above, you were using apollo instead of apollo-codegen

Solved by removing apollo and installing the new one. Then using new command for downloading schema : apollo schema:download --endpoint=https://something.com

I am facing this error using AWS-Amplify. apollo is part of Amplify now. I am facing the error like

error: Validation of GraphQL query document failed

@hshahdoost

EDIT
Finally fixed. Totally removed everything. npm, apollo etc. Deleted .grade file in Android Studio. Reinstalled everything (apollo-codegen not apollo) and it works now.

.grade file?

@kpjofficial no, There is nothing wrong with the .gradle file the apollo nodejs command is incompatible with the new apollo android. All you have to do is to the use the old apollo-codegen instead. here is a list of available versions install the old version and use it to generate your schema file.

I am using it as part of AWS Amplify, and it does not require separate apollo installation. For me, this error was due to bad query nomenclature in AppSync. Amplify automatically generates all the files in android based on the graphql queries and there was issue in it. I solved it by using new graphql schema with proper naming conventions, so that the files generated in Android does not throw this error.

Do not use any special characters in the graphql in AppSync, apollo (here, Amplify) messes it up.

Hey @kpjofficial, I am facing the same issue, which naming conventions have you used to fix it?

@Nieltz By naming conventions, I meant to avoid usage of special characters and naming in camelcase but then you can also check
https://facebook.github.io/graphql/June2018/#sec-Appendix-Notation-Conventions

@kpjofficial no, There is nothing wrong with the .gradle file the apollo nodejs command is incompatible with the new apollo android. All you have to do is to the use the old apollo-codegen instead. here is a list of available versions install the old version and use it to generate your schema file.

I recently tried apollo-codegen, after receiving the incompatibility of apollo result:
apollo-codegen download-schema http://localhost:8080/graphql/
but actually, the error says nothing:
error: Errors in introspection query result:
...

apollo-codegen --version
0.20.2

I'm stuck here.

Also having the same issue. I installed apollo-codegen to create the schema.json but I'm still getting a build failure with exit code 1.

Fixed for me:

The schema generated by
apollo schema:download --endpoint=http://localhost:8080/graphql
or
apollo service:download --endpoint=http://localhost:8080/graphql

results without the "data" name.

Adding

{
  "data": {
    "__schema": {...}
  }
}

with the corresponding spaces, finished the ':generateMainApolloIR' subtask, generating the classes for the queries on *.graphql files successfully.

Fixed for me:

The schema generated by
apollo schema:download --endpoint=http://localhost:8080/graphql
or
apollo service:download --endpoint=http://localhost:8080/graphql

results without the "data" name.

Adding

{
  "data": {
    "__schema": {...}
  }
}

with the corresponding spaces, finished the ':generateMainApolloIR' subtask, generating the classes for the queries on *.graphql files successfully.

Been stuck on this , still not working , can you just walk me through what steps you took ,

Apollo gradle plugin version etc.

:(

Was this page helpful?
0 / 5 - 0 ratings