question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Expo 42] Bare app build failing

See original GitHub issue

Edit Due to a mix of different underlying causes, we have locked this issue. Please read through this comment to find out how you can resolve this issue.


Summary

Android app fails to build on Task :unimodules-react-native-adapter:compileDebugJavaWithJavac

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

No response

Environment

Expo CLI 4.7.2 environment info: System: OS: Windows 10 10.0.19043 Binaries: Node: 14.17.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD SDKs: Android SDK: API Levels: 26, 29, 30 Build Tools: 29.0.2, 30.0.3 System Images: android-28 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-S | Google Play Intel x86 Atom_64 IDEs: Android Studio: Version 4.2.0.0 AI-202.7660.26.42.7351085 npmPackages: expo: ~42.0.0 => 42.0.0 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: ~0.63.4 => 0.63.4 react-native-web: ~0.13.12 => 0.13.18 Expo Workflow: bare

Reproducible demo or steps to reproduce from a blank project

Initialize a new Expo Bare App Setup typescript (only creating the tsconfig.json and installing the deps when prompted by expo start) Add eslint (config universe/native and the plugin simple-import-sort) Try to yarn android and it shoud fail on the task mentioned above

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
rajeshdecommented, Jul 8, 2021

Make sure to clean your cache, not only yarn or npm’s cache but also the gradle cache. To double-check the fix, I created this repository that contains two workflows. It creates a new project on the fly, changes the @unimodules/react-native-adapter version, and tries to build it. You can see the result for Windows, MacOS, and Ubuntu running before and after the released fix.

I still ran into error when trying a similar workflow on a local MacOS machine /.gradlew assembleDebug

node:internal/modules/cjs/loader:930
  throw err;
  ^

Error: Cannot find module 'expo-modules-autolinking'
Require stack:
- /Users/user/.gradle/daemon/6.8/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
    at Function.Module._load (node:internal/modules/cjs/loader:772:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at [eval]:1:1
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:81:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:80:60) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/user/.gradle/daemon/6.8/[eval]' ]
}
> Task :unimodules-react-native-adapter:compileDebugJavaWithJavac FAILED
/Users/user/Workspace/ExpoIssue13475Fix/node_modules/@unimodules/react-native-adapter/android/src/main/java/org/unimodules/adapters/react/ModuleRegistryAdapter.java:26: error: cannot find symbol
   mModuleRegistryProvider = new ReactModuleRegistryProvider(new ExpoModulesPackageList().getPackageList(), null);
                                                                 ^
 symbol:   class ExpoModulesPackageList
 location: class ModuleRegistryAdapter
1 error

FAILURE: Build failed with an exception.

Steps I followed:

1. Run expo init ExpoIssue13475Fix --template expo-template-bare-minimum@42
2. Add "resolutions": { "@unimodules/react-native-adapter": "6.3.2" } to package.json
3. Run yarn install
4. Run ./gradlew assembleDebug at Android folder

yarn why @unimodules/react-native-adapter

=> Found "@unimodules/react-native-adapter@6.3.2"
info Reasons this module exists
   - "expo" depends on it
   - Hoisted from "expo#@unimodules#react-native-adapter"
   - Hoisted from "react-native-unimodules#@unimodules#react-native-adapter"
info Disk size without dependencies: "3.02MB"
info Disk size with unique dependencies: "3.7MB"
info Disk size with transitive dependencies: "9.26MB"
info Number of shared dependencies: 44

Machine info

Macbook Air M1
nodejs v16.4.2. (arm64)
java 1.8 (arm64)
Android SDK 29.0.3

I finally made it work by the following steps, it will help anyone who come across this. Thanks for everyone advice!

1. Set gradle version to 6.9
2. Remove .gradle folder under android
3. Clean && compile again
  1. Upgraded Node to v14.17.3
  2. Upgraded Gradle to 6.9
  3. Removed .gradle folder
  4. Cleared all npm and react native caches
  5. Clean and Rebuild

Unfortunately, its still failing. Getting this below error.

Screenshot 2021-07-08 at 9 45 07 AM
4reactions
byCedriccommented, Jul 5, 2021

Hey all! I’m sorry for this issue and I can confirm this happens on Windows. I created a patch to fix this, I hope we can roll this out asap. If you absolutely need this to work, including on CI, you can work with patch-package until it is released.

You’ll need to create a file in patches/@unimodules+react-native-adapter+6.3.1.patch, with this content:

diff --git a/node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle b/node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle
index aedcef3..1e5903e 100644
--- a/node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle
+++ b/node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle
@@ -94,7 +94,7 @@ class ExpoAutolinkingManager {
     String[] args = [
       'node',
       '--eval',
-      'require("expo-modules-autolinking")(process.argv.slice(1))',
+      'require(\'expo-modules-autolinking\')(process.argv.slice(1))',
       '--',
       command,
       '--platform',

Here is a short guide to set that up:

  1. Install patch-package as dev dependency yarn add --dev patch-package
  2. Add the postinstall hook to your package.json "scripts": { "postinstall": "patch-package" }
  3. Create folder patches mkdir patches
  4. Copy over the contents from above into: patches/@unimodules+react-native-adapter+6.3.1.patch
  5. Run yarn to apply the patch

If you commit the patch and changes in your package.json, this is applied in CI, classic build, and on EAS.

Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bare Expo app unable to build when created first time ...
I created a react native app using expo init AwesomeProject. I chose bare workflow. As soon as I try to run the app...
Read more >
Troubleshooting build errors and crashes
Your build will fail. The build will succeed but encounter a runtime error, for example, it crashes or hangs when you run it....
Read more >
expo sdk 43
You can build a dev client using Expo's build service. ... install expo-updates If you're installing this in a bare React Native app, ......
Read more >
Expo Eas Local Build Failed : r/reactnative
I was giving a chance to expo for the first time today after doing RN bare for ~2 years. Why can't I "npx...
Read more >
failed to install expo package with error: yarnpkg exited ...
Try deleting yarn.lock file & .expo folder and try running expo upgrade again. It worked for me upgrading expo from 44 -> 45....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found