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:

2 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

(post deleted by author)

Just to double check,
Have you tried?

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