Android Build Failed in 5.4.4 Context.RECEIVER_EXPORTED error: cannot find symbol

[2024.08.30-13.59.12:881][441]UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\BatteryReceiver.java:89: error: cannot find symbol
[2024.08.30-13.59.12:881][441]UATHelper: Packaging (Android (ASTC)):         activity.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
                                                   ^

I already solved it! It was working with 5.3 but in 5.4.4 I got that error.
So, the problem is:

  • Targeting a wrong (outdated) Android SDK API Level in Platforms → Android SDK.

Follow the instructions:

I wanted to build for Quest2 (Android), so I follow the instructions here too:

So:

  • I downgraded Android Studio to the Flamingo version (instructions in the docs above)
    • Added the sdk platforms 34 and 32 (following the instructions in the Meta Quest VR above)
  • Deleted my Windows Environment Vars:
    • NDK_ROOT
    • NDKROOT
  • Downloaded and added the Java SDK in C:\Program Files\jdk-17.0.10
  • Updated my JAVA_HOME (instruction in the Meta Quest VR)

In the Meta Instructions, they let things in C:\ and with the defaults installation path etc to avoid crazy stuff, they’re right :laughing:

Now I can build for Android (Quest2) :pray:

4 Likes

Same version, same error :frowning:

Im having a similar error, on 5.4.4 just trying to package for Android ASTC.

UATHelper: Packaging (Android (ASTC)): Fixing minSdkVersion; NDK level is 33 which is above minSdkVersion 26.
UATHelper: Packaging (Android (ASTC)): Fixing targetSdkVersion; minSdkVersion is 33 which is above targetSdkVersion 30.
UATHelper: Packaging (Android (ASTC)): Fixing minSdkVersion; NDK level is 33 which is above minSdkVersion 26.
UATHelper: Packaging (Android (ASTC)): Fixing targetSdkVersion; minSdkVersion is 33 which is above targetSdkVersion 30.

...

UATHelper: Packaging (Android (ASTC)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:731: error: cannot find symbol
UATHelper: Packaging (Android (ASTC)): > Task :app:compileDebugJavaWithJavac
UATHelper: Packaging (Android (ASTC)):             activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (ASTC)):                            ^
UATHelper: Packaging (Android (ASTC)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (ASTC)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (ASTC)): Note: Some input files use or override a deprecated API.
UATHelper: Packaging (Android (ASTC)): Note: Recompile with -Xlint:deprecation for details.
UATHelper: Packaging (Android (ASTC)): 1 error
UATHelper: Packaging (Android (ASTC)): > Task :app:compileDebugJavaWithJavac FAILED
UATHelper: Packaging (Android (ASTC)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (ASTC)): * What went wrong:
UATHelper: Packaging (Android (ASTC)): Execution failed for task ':app:compileDebugJavaWithJavac'.
UATHelper: Packaging (Android (ASTC)): > Compilation failed; see the compiler error output for details.
UATHelper: Packaging (Android (ASTC)): * Try:
UATHelper: Packaging (Android (ASTC)): > Run with --stacktrace option to get the stack trace.
UATHelper: Packaging (Android (ASTC)): 54 actionable tasks: 54 executed
UATHelper: Packaging (Android (ASTC)): > Run with --info or --debug option to get more log output.
UATHelper: Packaging (Android (ASTC)): > Run with --scan to get full insights.
UATHelper: Packaging (Android (ASTC)): * Get more help at https://help.gradle.org
UATHelper: Packaging (Android (ASTC)): BUILD FAILED in 29s

after checking the sdk versions etc. setting in the Project Settings
“Minimum SDK Version” and “Target SDK Version” to “29”
as well as
“NDK API Level” and “SDK API Level” to “android-29”
finally solved it for me.

1 Like

Strange, because I was using 32 for all my android versions in my project for 5.4.3, and the moment I upgrade to 5.4.4, it fails to build. Now it builds, thanks to your advice. Thank you, my friend.

Well, the good thing is that after adding 29, it worked, the package closed… The bad thing is that my project no longer opens in quest3

Ok, now works, but my passthrough stay black in quest 3. after open my app

Just to double check,
Have you tried?

  • Meta XR Tools -> Meta XR Project Setup Tool -> Quest 3 -> Fix All

Update the SDK versions under: Project Settings/Platforms/Android/Target SDK version to 34 and change Project Settings/Platform/Android/SDK API Level to android-34.

I’ve updated the guide. You’ll also be able to build and run on Quest3 using these versions. Keep in mind its now also a requirement to ship on the Meta Store, 34 time everyone :slight_smile:

TARGET_SDK_VERSION_TOO_HIGH

Android Target SDK version is 34, but should be 32 or lower (targetSdkVersion in AndroidManifest.xml).

This error message you will get if you will try to upload SDK 34 build to Meta Quest Developer Hub.

Any suggestion what to do now?

2 Likes

I’ve updated the Tutorial covering Distribution (shipping), and provided guidance on signing, packaging and uploading to Meta Quest Hub / App Distribution.

1 Like

Thanks! already published with 5.4.3. and sdk 32.

1 Like

I updated the tutorial to include distribution, if anyone in the future runs into issues.

This has been an absolutely horrific developer experience. Ideally, there’d be an install button that you push, and the correct version of Android Studio, the correct SDK, NDK, etc are all installed, and a project is configured with the info. This has been a guessing game for far too many for far too long.

Currently, I can package with android-29, android-33, and 34, but can’t deploy.

I can’t package with android-32, the one version I need.

How can we fix this?

This is driving developers to Unity for Quest development.

I can package with android-34, but I can’t deploy. Have you been able to deploy to Quest3 with 34?