r/reactnative • • 9h ago

Help Build fails. On a ChromeOS for Android.

I am trying to create an Android only project with react native, but I can't have it to build.

I am running on a Chromeos arm64 and I have Android SDK, NDK, Ninja, CMake, AAPT, ADB, etc installed.

With "./gradlew clean" it builds the project, but not with "assembleDebug" nor "npx run android".

I have:

node: 20.20.2
npm: 10.8.0
react native: 0.88.1
gradle: 9.4.1
--
buildToolsVersion = "37.0.0"
minSdkVersion = 24
compileSdkVersion = 37
targetSdkVersion = 36
ndkVersion = "31.0.16996043-beta1"
kotlinVersion = "2.2.0"

Here's the output:

> Configure project :react-native-safe-area-context
WARNING: API 'libraryVariants' is obsolete and has been replaced with 'AndroidComponentsExtension'.
It will be removed in version 10.0 of the Android Gradle plugin.
The legacy variant API is disabled by default in AGP 9.0, but can be re-enabled by adding 
    android.newDsl=false
to this project's gradle.properties file.
For more information, see http://developer.android.com/build/r/new-dsl.

To determine what is calling libraryVariants, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Task :app:processDebugResources FAILED

[Incubating] Problems report is available at: file:///home/gesf/Repositories/lawstMobile/android/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.4.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
62 actionable tasks: 4 executed, 58 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

AAPT2 aapt2-9.2.1-15009934-linux Daemon #0: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected
AAPT2 aapt2-9.2.1-15009934-linux Daemon #1: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected
AAPT2 aapt2-9.2.1-15009934-linux Daemon #2: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform react-android-0.88.1-debug.aar (com.facebook.react:react-android:0.88.1) to match attributes {artifactType=android-compiled-dependencies-resources, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/d5146b3e036e066bc8c4a18a4fbb39c7/transformed/jetified-react-android-0.88.1-debug.
         > AAPT2 aapt2-9.2.1-15009934-linux Daemon #0: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/5d72c5a5e5f8f71190a2421fff6f4f77/transformed/appcompat-1.7.0.
         > AAPT2 aapt2-9.2.1-15009934-linux Daemon #2: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
   > Failed to transform core-1.13.1.aar (androidx.core:core:1.13.1) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/58ba09cce1dd261f23b73f746b96937a/transformed/core-1.13.1.
         > AAPT2 aapt2-9.2.1-15009934-linux Daemon #1: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 15s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
AAPT2 aapt2-9.2.1-15009934-linux Daemon #0: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected
AAPT2 aapt2-9.2.1-15009934-linux Daemon #1: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected
AAPT2 aapt2-9.2.1-15009934-linux Daemon #2: Unexpected error output: /home/gesf/.gradle/caches/9.4.1/transforms/b75a69aa854e4ca1a60ee64c64b60172/transformed/aapt2-9.2.1-15009934-linux/aapt2: 1: Syntax error: ")" unexpected FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform react-android-0.88.1-debug.aar (com.facebook.react:react-android:0.88.1) to match attributes {artifactType=android-compiled-dependencies-resources, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/d5146b3e036e066bc8c4a18a4fbb39c7/transformed/jetified-react-android-0.88.1-debug. > AAPT2 aapt2-9.2.1-15009934-linux Daemon #0: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. > Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/5d72c5a5e5f8f71190a2421fff6f4f77/transformed/appcompat-1.7.0. > AAPT2 aapt2-9.2.1-15009934-linux Daemon #2: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. > Failed to transform core-1.13.1.aar (androidx.core:core:1.13.1) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for AarResourcesCompilerTransform: /home/gesf/.gradle/caches/9.4.1/transforms/58ba09cce1dd261f23b73f746b96937a/transformed/core-1.13.1. > AAPT2 aapt2-9.2.1-15009934-linux Daemon #1: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does.

Thanks in advance!

2 Upvotes

6 comments sorted by

3

u/Careless_Cycle5991 8h ago

that Syntax error: ")" unexpected is the giveaway. the aapt2 gradle pulls from maven is an x86_64 linux binary, so on an arm64 chromebook it can't exec and the shell ends up trying to read it as a script. clean works because it never calls aapt2.

you need an arm64 build of aapt2 (termux has one, there are also prebuilt android-sdk-tools builds on github) and then point gradle at it in gradle.properties:

android.aapt2FromMavenOverride=/path/to/aapt2

try to get a version close to your AGP's aapt2.

1

u/gesfontoura 8h ago

Thank you! It makes sense to me. Will give it a try!

2

u/MeasurementGreat5273 6h ago

processDebugResources failing on arm64 is usually the aapt2 that Gradle downloads from Maven, it's an x86_64 binary and can't run on your machine. Point it at the arm64 one from your SDK build-tools with android.aapt2FromMavenOverride=/path/to/Sdk/build-tools/37.0.0/aapt2 in ~/.gradle/gradle.properties. The real error is above the summary, run with --stacktrace and look for the aapt2 daemon startup failure.

1

u/gesfontoura 4h ago

Nothing seems to work :/

1

u/MeasurementGreat5273 3h ago

Did you try the aapt2 override in gradle.properties? Also paste the actual error from the processDebugResources task, the lines under it, that's where it says why it fails