Trying to use rescript react native

To create the project, I have ran the following command:

npx @react-native-community/cli init --template @rescript-react-native/template TestApp

It works fine. However, when I run the following command to run the app on my Android device (it’s connected via USB and adb labels it as connected):

npx react-native run-android --deviceId=ZY22F72NHS

I receive this error. What did I do wrong, and how can I solve this (I can provide more info if needed):

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-aar-metadata, 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 JetifyTransform: /home/User/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-native/0.71.0-rc.0/7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543/react-native-0.71.0-rc.0-debug.aar.
         > Java heap space```

That template is a bit outdated, could you please run a npx react-native upgrade in the TestApp directory and try again? You may need to set the compileSdkVersion in android/build.gradle to a higher level as well.

Thank you for that information. I will try it when I am at my computer in a few hours. In the meantime, I have two questions:

  1. I got that command from the current Rescript react native guide. But it’s outdated. That kinda makes me wonder: Is the whole project still actively maintained?

  2. I read that I will be needing to use a lot of community components because React lacks a lot of things built in. Will I have to manually write bindings for those components?

  1. rescript-react-native itself is actively maintained by @MoOx and others, but I guess nobody had the time to update the template yet. I think there are just not enough people that use it, most will probably just use the init mechanism without the template parameter and add ReScript manually.

  2. Concerning react-native, there are lots of bindings out there but most people keep them locally in their projects so they can quickly update them. So yeah, you will need to write lots of bindings probably.

rescript-react-native itself is up to date with latest stable version.
Worst thing that can happen when we do not update bindings it that you may miss a prop or 2 for some components. You can always create issue and/or use patch-package temporarily.

For community components, you can use a few that we are publishing, but not always up to date with latest package. It’s a lot of work to follow all this packages & update bindings every time. Mostly time consuming as most of the time, there is very little adds/changes to bindings.

You can finds tons of bindings (direct usage if ok for you - or as examples to write your own) @rescript-react-native · GitHub

You can always write bindings yourself for small libs. Pretty easy when you have examples (even outdated).

Be sure to poke me on some repos if bindings are out of date and/or feel free to contribute. I can help/guide you if you want.

1 Like

Thank you both. As for npx react-native upgrade command when run:

info Fetching diff between v0.64.0 and v0.70.6...
error Command failed: git status -s
fatal: not a git repository (or any of the parent directories): .git


Error: Command failed: git status -s
fatal: not a git repository (or any of the parent directories): .git```

git init

@MoOx should the template come with a git folder?

success Upgraded React Native to v0.70.6 🎉. Now you can review and commit the changes

Should I git commit too?

I ran git commit and now I get these lovely :heart: errors when I try to run the app:

> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat:1.4.1.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/3aeebd481c4b979f4aaf1422ab700cb2/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.appcompat:appcompat-resources:1.4.1.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/5037444d0e4e7ecd374e14c9cde1a9e9/jetified-appcompat-resources-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2-views-helper:1.0.0.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/42e939cb6ff04968d17f51f220845a50/jetified-emoji2-views-helper-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.emoji2:emoji2:1.0.0.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/6d54bbfebc644b955342f5222212631f/jetified-emoji2-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.core:core:1.7.0.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/e596bd84a87a4cbdcf9d545f7eacbd1e/core-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.lifecycle:lifecycle-process:2.4.0.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/b4f70e2aa5cce10e50e20d9b8e994481/jetified-lifecycle-process-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-29).
        Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
        AAR metadata file: /home/user/.gradle/caches/transforms-2/files-2.1/7e88b296a48384d725962d71d07ec64e/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

I got it to work. In case someone else is in my position, from the beginning, these are the things I had to do:

  • git init
  • npx react-native upgrade
  • git commit
  • change compileSdkVersion to compileSdkVersion = 31 in my build.gradle

To finally run the app, I also had to keep metro running in the background by running npx react-native start in a separate terminal, on top of running that npx react-native run-android --deviceId=ZY22F72NHS command.

1 Like

react-native upgrade use git to works properly !

I will try to update the template someday, or delete it and create instruction to quickly make your own for react native standard template + one command + one copy paste.

2 Likes