Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Preview APK build failing locally #30413

Open
MariuzM opened this issue Jul 15, 2024 · 10 comments
Open

Android Preview APK build failing locally #30413

MariuzM opened this issue Jul 15, 2024 · 10 comments
Labels
CLI Versioned Expo CLI -- `npx expo start`

Comments

@MariuzM
Copy link
Contributor

MariuzM commented Jul 15, 2024

Summary

When i use EXPO_USE_DEV_SERVER=true NODE_OPTIONS=--max_old_space_size=2048 bx eas build --profile preview --local -p android i get Build Failed

image

Its just this particular app that i have inherited has this issue, but if do production build where it builds aab its fine.

Here i have tried with 4gb memory

[RUN_GRADLEW] File system event consumer thread stopped due to exception
[RUN_GRADLEW] java.lang.OutOfMemoryError: Java heap space
[RUN_GRADLEW] java.lang.OutOfMemoryError: Java heap space
[RUN_GRADLEW] Exception in thread "Daemon client event forwarder" java.lang.OutOfMemoryError: Java heap space
[RUN_GRADLEW] ERROR: Exception while analyzing expression in (91,39) in /private/var/folders/nq/9t468y2j4bn2nmqfswkm0kcw0000gn/T/eas-build-local-nodejs/3c83c51f-2df2-4ba6-8808-ce64ad0fdd37/build/node_modules/expo-dev-menu/android/src/main/java/expo/modules/devmenu/react/DevMenuPackagerCommandHandlersSwapper.kt
[RUN_GRADLEW] Attachments:
[RUN_GRADLEW] causeThrowable
[RUN_GRADLEW] java.lang.OutOfMemoryError: Java heap space
[RUN_GRADLEW] org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Exception while analyzing expression in (91,39) in /private/var/folders/nq/9t468y2j4bn2nmqfswkm0kcw0000gn/T/eas-build-local-nodejs/3c83c51f-2df2-4ba6-8808-ce64ad0fdd37/build/node_modules/expo-dev-menu/android/src/main/java/expo/modules/devmenu/react/DevMenuPackagerCommandHandlersSwapper.kt
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.logOrThrowException(ExpressionTypingVisitorDispatcher.java:253)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:225)
[RUN_GRADLEW]   at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:165)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:135)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getTypeInfo(ExpressionTypingServices.java:126)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver.resolveValueArgument(PSICallResolver.kt:818)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver.resolveArgumentsInParenthesis(PSICallResolver.kt:754)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver.toKotlinCall(PSICallResolver.kt:613)
[RUN_GRADLEW] > Task :expo-dev-launcher:lintVitalAnalyzeRelease
[RUN_GRADLEW] > Task :expo-dev-menu:lintVitalAnalyzeRelease
[RUN_GRADLEW] at org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver.toKotlinCall$default(PSICallResolver.kt:589)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.tower.PSICallResolver.runResolutionAndInference(PSICallResolver.kt:109)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallResolver.doResolveCallOrGetCachedResults(CallResolver.java:602)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallResolver.lambda$computeTasksAndResolveCall$0(CallResolver.java:213)
[RUN_GRADLEW]   at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallResolver.computeTasksAndResolveCall(CallResolver.java:211)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallResolver.computeTasksAndResolveCall(CallResolver.java:199)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallResolver.resolveFunctionCall(CallResolver.java:329)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallExpressionResolver.getResolvedCallForFunction(CallExpressionResolver.kt:86)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallExpressionResolver.getCallExpressionTypeInfoWithoutFinalTypeCheck(CallExpressionResolver.kt:208)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallExpressionResolver.getUnsafeSelectorTypeInfo(CallExpressionResolver.kt:332)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallExpressionResolver.getSafeOrUnsafeSelectorTypeInfo(CallExpressionResolver.kt:382)
[RUN_GRADLEW]   at org.jetbrains.kotlin.resolve.calls.CallExpressionResolver.getQualifiedExpressionTypeInfo(CallExpressionResolver.kt:480)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.BasicExpressionTypingVisitor.visitQualifiedExpression(BasicExpressionTypingVisitor.java:725)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.visitQualifiedExpression(ExpressionTypingVisitorDispatcher.java:391)
[RUN_GRADLEW]   at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher$ForBlock.visitQualifiedExpression(ExpressionTypingVisitorDispatcher.java:60)
[RUN_GRADLEW]   at org.jetbrains.kotlin.psi.KtVisitor.visitDotQualifiedExpression(KtVisitor.java:306)
[RUN_GRADLEW]   at org.jetbrains.kotlin.psi.KtDotQualifiedExpression.accept(KtDotQualifiedExpression.kt:32)

What platform(s) does this occur on?

Android

SDK Version

51

Environment

expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.5
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - ~/dev/node-v20.11.0/bin/node
Yarn: 1.22.22 - ~/dev/node-v20.11.0/bin/yarn
npm: 10.2.4 - ~/dev/node-v20.11.0/bin/npm
Managers:
CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5
Android SDK:
Android NDK: 26.2.11394342
IDEs:
Xcode: 15.4/15F31d - /usr/bin/xcodebuild
npmGlobalPackages:
eas-cli: 10.1.1

Minimal reproducible example

https://github.com/MariuzM/expo-starter
I'm just linking this here to BOT allows it, but this is not the example, i can't post right now production example.

@MariuzM MariuzM added CLI Versioned Expo CLI -- `npx expo start` needs validation Issue needs to be validated labels Jul 15, 2024
@expo-bot expo-bot removed the needs validation Issue needs to be validated label Jul 15, 2024
@MariuzM
Copy link
Contributor Author

MariuzM commented Jul 15, 2024

I then tried like this bun run eas build --profile preview --local -p android even tho i have bun by default my maybe explicit saying bun run helps?

@MariuzM
Copy link
Contributor Author

MariuzM commented Jul 15, 2024

No still an issue, its just random, i tried production profile with apk setting but same :(

@computerjazz
Copy link
Contributor

Similar issue here. Release builds work fine on EAS but fail when I build locally. I tried to edit gradle.properties to match the values here but no luck: https://docs.expo.dev/build-reference/infrastructure/#android-build-server-configurations

org.gradle.jvmargs=-Xmx14g -XX:MaxPermSize=512m -XX: HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=false 

@computerjazz
Copy link
Contributor

I ended up creating a global gradle.properties with the following and it started building:

org.gradle.jvmargs=-Xmx14g -XX:MaxMetaspaceSize=512m -XX: HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=false

setting up global gradle properties: https://www.labkey.org/Documentation/wiki-page.view?name=gradleProps#global
note on jvmargs: https://stackoverflow.com/a/75897214

@MariuzM
Copy link
Contributor Author

MariuzM commented Jul 24, 2024

Thanks @computerjazz this really helped also noticed that my build speeds are like 2x almost fast, wish iOS had this simple improvement also

@vonovak
Copy link
Contributor

vonovak commented Jul 24, 2024

Hello and thanks for asking,
As was previously pointed out, this is an issue with Java and the amount of memory is has available. Given that it's resolved, I'm going to close the issue.

Thank you 🙂

@vonovak vonovak closed this as completed Jul 24, 2024
@MariuzM
Copy link
Contributor Author

MariuzM commented Jul 24, 2024

But i don’t think this should be a resolved issue, i feel this is something expo could implement so people don’t need todo workarounds

@vonovak
Copy link
Contributor

vonovak commented Jul 24, 2024

Hi! It's true that we can probably increase the defaults that are included in the android project config, so I'll keep this open.
Just note that the provided fix is not a workaround, it's the correct way to resolve the lack of memory that you're seeing.

Thank you 👍

@vonovak vonovak reopened this Jul 24, 2024
@frozencap
Copy link

great interaction: proper fix and clear resolution steps for the maintainers

@ljmzbigsmart
Copy link

I ended up creating a global gradle.properties with the following and it started building:

org.gradle.jvmargs=-Xmx14g -XX:MaxMetaspaceSize=512m -XX: HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=false

setting up global gradle properties: https://www.labkey.org/Documentation/wiki-page.view?name=gradleProps#global note on jvmargs: https://stackoverflow.com/a/75897214

Damn! FINALLY something that actually worked! I tried a lot of things like setting Node ENV variables and stuff. This instantly made the difference. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Versioned Expo CLI -- `npx expo start`
Projects
None yet
Development

No branches or pull requests

6 participants