Please provide the following:
- SDK Version: 42
- Platforms(Android/iOS/web/all): Android/iOS
- Add the appropriate “Tag” based on what Expo library you have a question on.
Issue
Some background: we’ve had expo-cli
as a dev dependency since our project began in mid 2019. We like to have our team on the same version and we love the simplicity of running yarn install
and having everything ready to go. We’re using the bare workflow.
During the process of upgrading to expo-cli ^5.0.1
using Yarn 2, builds (locally and on EAS) began failing with:
Android:
> Task :expo:compileDebugJavaWithJavac FAILED
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:6: error: package expo.modules.kotlin.modules does not exist
import expo.modules.kotlin.modules.Module;
^
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:7: error: package expo.modules.kotlin does not exist
import expo.modules.kotlin.ModulesProvider;
^
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:9: error: cannot find symbol
public class ExpoModulesPackageList implements ModulesProvider {
^
symbol: class ModulesProvider
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:34: error: cannot find symbol
public List<Class<? extends Module>> getModulesList() {
^
symbol: class Module
location: class expo.modules.ExpoModulesPackageList
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:24: error: cannot find symbol
static final List<Class<? extends Module>> modulesList = Arrays.<Class<? extends Module>>asList(
^
symbol: class Module
location: class expo.modules.ExpoModulesPackageList.LazyHolder
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:24: error: cannot find symbol
static final List<Class<? extends Module>> modulesList = Arrays.<Class<? extends Module>>asList(
^
symbol: class Module
location: class expo.modules.ExpoModulesPackageList.LazyHolder
/Users/cam/Source/expo-test/node_modules/expo/android/build/generated/expo/src/main/java/expo/modules/ExpoModulesPackageList.java:33: error: method does not override or implement a method from a supertype
@Override
^
7 errors
and iOS builds fail with:
› Compiling expotest » ExpoModulesProvider.swift
❌ (ios/Pods/Target Support Files/Pods-expotest/ExpoModulesProvider.swift:17:56)
15 | }
16 |
> 17 | public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
| ^ cannot find type 'ExpoAppDelegateSubscriber' in scope
18 | return [
19 | ]
20 | }
❌ (ios/Pods/Target Support Files/Pods-expotest/ExpoModulesProvider.swift:17:24)
15 | }
16 |
> 17 | public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
| ^ method does not override any method from its superclass
18 | return [
19 | ]
20 | }
› 2 error(s)
Steps to reproduce:
expo init expo-test -t bare-minimum
cd expo-test
yarn ios # Everything working fine
yarn android # Everything working fine
yarn set version berry # Migrate to Yarn 2
yarn install
xcodebuild clean -workspace ios/expotest.xcworkspace -scheme expotest # Clean the build
cd android && ./gradlew clean && cd .. # Clean the build
yarn ios # Everything working fine
yarn android # The Android build breaks at this point
yarn add --dev expo-cli
xcodebuild clean -workspace ios/expotest.xcworkspace -scheme expotest
cd android && ./gradlew clean && cd ..
yarn ios # Broken
yarn android # Broken
Android cause
We believe there is a breaking change in expo-modules-autolinking ~0.4.0
and if we take an action that puts 0.4.0
at the top level of node_modules
, things break.
When starting a new project from scratch, the problem doesn’t present itself until after upgrading to Yarn 2. The node_modules
structure changes during the upgrade.
Yarn 1
expo-modules-autolinking
is present at:
-
node_modules/expo-modules-prelinking
(0.3.4
) -
node_modules/@expo/prebuild-config/node_modules/expo-modules-autolinking
(0.4.0
)
Yarn 2
expo-modules-autolinking
is present at:
-
node_modules/expo-modules-autolinking
(0.4.0
) -
node_modules/expo/node_modules/expo-modules-autolinking
(0.3.4
)
Our workaround
expo 43.0.4
depends on expo-modules-autolinking ~0.3.4
but @expo/prebuild-config
depends on expo-modules-autolinking ~0.4.0
.
@expo/prebuild-config
is being required from expo-splash-screen
, which is asking for @expo/prebuild-config ^3.0.6
.
@expo/prebuild-config
versions >= 3.0.12
introduced a dependency of expo-modules-autolinking ~0.4.0
, thereby tipping the scales and forcing Yarn 2 to put the most requested version at the top, and the lesser requested version in the node_modules
directory inside expo
. Our workaround is to use resolutions
in Yarn to forcibly select @expo/prebuild-config < 3.0.12
by adding the following to package.json
:
...
"resolutions": {
"@expo/prebuild-config": "< 3.0.12"
}
...
This is enough to tip the scales to force Yarn 2 to once again put expo-modules-autolinking 0.3.4
at the top level.
iOS cause
We don’t really know why adding expo-cli
as a dev dependency breaks the iOS build but we believe it to be related to the Android problem, because the resolutions
workaround solves it too.