Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Android building error android/gradlew exited with non-zero code: 1 #31

Closed
petkobonev opened this issue Jan 31, 2024 · 19 comments
Closed
Labels
android duplicate This issue or pull request already exists question Further information is requested

Comments

@petkobonev
Copy link

Hey, great work on this guide. Really appreciate you putting it together.

Here's the error I'm seeing after expo run:android:

✖ Error: /Users/pbonev/react/thisisdope-app/android/gradlew exited with non-zero code: 1
Error: /Users/pbonev/react/thisisdope-app/android/gradlew exited with non-zero code: 1
at ChildProcess.completionListener (/Users/pbonev/react/thisisdope-app/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
at Object.onceWrapper (node:events:628:26)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5)
...
at Object.spawnAsync [as default] (/Users/pbonev/react/thisisdope-app/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
at spawnGradleAsync (/Users/pbonev/react/thisisdope-app/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
at Object.assembleAsync (/Users/pbonev/react/thisisdope-app/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
at runAndroidAsync (/Users/pbonev/react/thisisdope-app/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.Some info that may or may not be relevant:

Expo 49
I'm in a yarn v1 workspace with my Expo app located at /packages/app, and package.json files at /package.json and /packages/app/package.json.
plugins and patches dirs copied to /plugins and /patches, not to /packages/app/*
/packages/app/package.json postinstall: expo-yarn-workspaces postinstall && patch-package
postinstall-postinstall package not installed
app.config.js plugins section:

@achorein
Copy link
Owner

can you give the output of the following command npx react-native info ?
do you have any issue with the demo, it sounds like an integration on your own project problem.

@petkobonev
Copy link
Author

Yeah, i have the integration issue, here is the output:

System: OS: macOS 13.4 CPU: (8) arm64 Apple M2 Memory: 76.80 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 19.9.0 path: ~/.nvm/versions/node/v19.9.0/bin/node Yarn: version: 1.22.21 path: ~/react/thisisdope-app/node_modules/.bin/yarn npm: version: 9.6.3 path: ~/.nvm/versions/node/v19.9.0/bin/npm Watchman: Not Found Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: - DriverKit 22.4 - iOS 16.4 - macOS 13.3 - tvOS 16.4 - watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: version: 14.3.1/14E300c path: /usr/bin/xcodebuild Languages: Java: version: 20.0.1 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.4 wanted: 0.72.4 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: Not found newArchEnabled: Not found /

@achorein
Copy link
Owner

achorein commented Jan 31, 2024

postinstall-postinstall package not installed
did you forget to install this dep ? yarn add postinstall-postinstall

@achorein achorein added the question Further information is requested label Jan 31, 2024
@petkobonev
Copy link
Author

It's installed, nothing has changed.

@achorein
Copy link
Owner

after yarn install you should have this output :
image

and this after prebuild:
image

you error log message is incomplete and don't give the main error, I need the initial error before exited with non-zero code: 1 in order to help you.

@petkobonev
Copy link
Author

petkobonev commented Jan 31, 2024

Yes i have this outputs, but when try prebuild it gives me this ->
`yarn run v1.22.19
$ /Users/pbonev/react/thisisdope-app/node_modules/.bin/expo prebuild
✔ Created native projects | /android, /ios already created | gitignore skipped
› Using current versions instead of recommended [email protected].
✔ Updated package.json and added index.js entry point for iOS and Android
› Installing using yarn

yarn install
⠙ Config syncing************ scheme thisisdope
✖ Config sync failed
TypeError: [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path')
TypeError: [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path')
at correctForPath (/Users/pbonev/react/thisisdope-app/node_modules/xcode/lib/pbxProject.js:1682:38)
at correctForResourcesPath (/Users/pbonev/react/thisisdope-app/node_modules/xcode/lib/pbxProject.js:1672:12)
at pbxProject.addResourceFile (/Users/pbonev/react/thisisdope-app/node_modules/xcode/lib/pbxProject.js:258:9)
at /Users/pbonev/react/thisisdope-app/node_modules/expo-config-plugin-ios-share-extension/build/withShareExtensionXcodeTarget.js:37:20
at async action (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:201:23)
at async interceptingMod (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:105:21)
at async interceptingMod (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:105:21)
at async interceptingMod (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:105:21)
at async interceptingMod (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:105:21)
at async interceptingMod (/Users/pbonev/react/thisisdope-app/node_modules/@expo/config-plugins/build/plugins/withMod.js:105:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

I saw a similar issue opened about but nothing helped there.

@achorein
Copy link
Owner

achorein commented Jan 31, 2024

it seems that your xcode+3.0.1.patch has not been applied (like #22).
you can verify in this file : node_modules/xcode/lib/pbxProject.js, you should have if (project.pbxGroupByName(group)&&project.pbxGroupByName(group).path) on line 1681

@achorein achorein pinned this issue Jan 31, 2024
@achorein achorein unpinned this issue Jan 31, 2024
@achorein
Copy link
Owner

Duplicate of #22

@achorein achorein marked this as a duplicate of #22 Jan 31, 2024
@achorein
Copy link
Owner

achorein commented Feb 1, 2024

yarn patch-package will apply all patches

that's why we got the postinstall in the package.json

  "scripts": {
    ...
    "postinstall": "patch-package"
  }

@petkobonev
Copy link
Author

Yep, it worked,
image
After applying the patch and prebuild execution, ive got again the same error
image

@achorein
Copy link
Owner

achorein commented Feb 1, 2024

after the patch you need to clean up expo prebuild with : expo prebuild --no-install --clean

@petkobonev
Copy link
Author

Yep i did it, still the same ->
image

@achorein
Copy link
Owner

achorein commented Feb 1, 2024

can you check your android/gradle.properties, should have this at the end of the file :

android.kotlinVersion=1.6.10

if it's already the case, you can try to change the version like this in the app.json (clean prebuild)

  "plugins": [
      [
        "./plugins/withAndroidShareExtension/index",
        {
          ...
          "androidExtraBuildProperties": { 
             "kotlinVersion": "1.8.10"
          },
        }
      ],
  ],

@petkobonev
Copy link
Author

Yes the kotlin version is same as you described|

android.kotlinVersion=1.6.10

I applied the

  [
        "./plugins/withAndroidShareExtension/index",
        {
          "androidIntentFilters": ["text/*", "image/*"],
          "androidExtraBuildProperties": {
            "kotlinVersion": "1.8.10"
          }
        }
      ],

And still got the same issue.

@achorein
Copy link
Owner

achorein commented Feb 1, 2024

:/
seems related to your java version, you are using java 20.
Retry with java 18
(here for more information : https://stackoverflow.com/questions/67240279/could-not-open-settings-generic-class-cache-for-settings-file)

@achorein
Copy link
Owner

feel free to reopen if the problem persist

@joshmohrer
Copy link

Try adding this to your package.json

"overrides": {
"@expo/config-plugins": "~7.8.4"
},

@wodin
Copy link

wodin commented Feb 21, 2024

Adding resolutions/overrides for @expo/config-plugins is usually a bad idea. The expo package should pull in the correct version. If there's something else trying to pull in some other version, then that should be fixed.

@achorein
Copy link
Owner

achorein commented Feb 21, 2024

i'm working on new npm package which use a native module for android. Still in beta but you can give it a try with expo 50 https://www.npmjs.com/package/expo-share-intent

@achorein achorein added the duplicate This issue or pull request already exists label Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
android duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants