software-mansion / react-native-screens

Native navigation primitives for your React Native app.
MIT License
3.01k stars 510 forks source link

"ReactAndroid::react_performance_timeline" but the target was not found. C/C++: Perhaps a find_package() call is missing for an IMPORTED target, or an C/C++: ALIAS target is missing? #2334

Closed wogno closed 3 days ago

wogno commented 1 week ago

Description

When I tried to build apk or aab, I get error

Capture d’écran 2024-09-04 à 09 02 04 Capture d’écran 2024-09-04 à 09 02 33

Caused by: com.android.ide.common.process.ProcessException: Error while executing process /Users/.../Library/Android/sdk/cmake/3.22.1/bin/cmake with arguments {-H/Users/.../Documents/projects-software/my-projects/manage-app/.../node_modules/react-native-screens/android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=23 -DANDROID_PLATFORM=android-23 -DANDROID_ABI=arm64-v8a -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DANDROID_NDK=/Users/.../Library/Android/sdk/ndk/26.1.10909125 -DCMAKE_ANDROID_NDK=/Users/.../Library/Android/sdk/ndk/26.1.10909125 -DCMAKE_TOOLCHAIN_FILE=/Users/.../Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/.../Library/Android/sdk/cmake/3.22.1/bin/ninja -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/.../Documents/projects-software/my-projects/manage-app/.../node_modules/react-native-screens/android/build/intermediates/cxx/RelWithDebInfo/6u4o4p4p/obj/arm64-v8a -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/.../Documents/projects-software/my-projects/manage-app/.../node_modules/react-native-screens/android/build/intermediates/cxx/RelWithDebInfo/6u4o4p4p/obj/arm64-v8a -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_FIND_ROOT_PATH=/Users/.../Documents/projects-software/my-projects/manage-app/.../node_modules/react-native-screens/android/.cxx/RelWithDebInfo/6u4o4p4p/prefab/arm64-v8a/prefab -B/Users/.../Documents/projects-software/my-projects/manage-app/.../node_modules/react-native-screens/android/.cxx/RelWithDebInfo/6u4o4p4p/arm64-v8a -GNinja -DANDROID_STL=c++_shared -DRNS_NEW_ARCH_ENABLED=true} at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73) at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48) at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt.execute(ExecuteProcess.kt:277) ... 141 more Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/sandwidimohamed/Library/Android/sdk/cmake/3.22.1/bin/cmake'' finished with non-zero exit value 1 at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:431) at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46) ... 142 more

Steps to reproduce

  1. Clean cache
  2. Go on android directory
  3. ./gradlew assembleRelease

Snack or a link to a repository

https://snack.expo.io/no-have

Screens version

3.32.0

React Native version

0.74.2

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Release mode

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 1 week ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

tboba commented 1 week ago

Hi @wogno, thanks for reporting this issue! We can't reproduce it without proper reproducer provided. Could you attach correct project (or snack) that will reproduce this bug to the description of this issue?

kkafar commented 1 week ago

Yeah, we need a reproducer, case we're building this library every other minute and it works for us.

BenIrving commented 1 week ago

This happened for me when I tried to use rns version >3.33 on <rn75, as it requires the prefab targets added here

Are you sure you are building on 3.32?

wogno commented 1 week ago

@BenIrving yes, I upgrade rns to 3.34 but still faced the same issue, should I upgrade react native.

I debug mode with run android every work well, but when we want to build apk or aab, we faced this issue.

Capture d’écran 2024-09-05 à 10 09 47 Capture d’écran 2024-09-05 à 10 09 58

wogno commented 1 week ago

@BenIrving I also found this error, about add_library

CMake Error at CMakeLists.txt:6 (add_library): Target "rnscreens" links to target "ReactAndroid::react_render_consistency" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

kkafar commented 3 days ago

Hey @wogno, thing here is that support for Fabric in react-native-screens is a little bit convoluted, since the react-native team still frequently introduces breaking changes between minor versions of react-native. We have a very specific mapping of which react-native-screens versions do support which react-native versions. We public this mapping here in form of a table. react-native-screens@3.34 won't work with react-native@0.74 if you're using Fabric. As I've said - this is due to breaking changes between react-native versions 0.74 and 0.75 to which we had to conform between screens versions 3.32 & 3.33 to bring support for react-native@0.75.

I'm sorry, but to make things work this library utilises many react-native native-side APIs, and if there are breaking changes on the side of react-native, we have to follow along and break backward compatibility (this happens mostly only with new architecture though).

Best way to go is to use most recent versions of both libraries here.

I'll close the issue soon, since it seems that this is due to mismatch in versions or it applies to no longer supported react-native version (with new architecture turned on).

kkafar commented 3 days ago

Actually I'll reopen if you say the issue is reproducible on react-native@0.75 with most recent screens version.

wogno commented 3 days ago

Thanks for your help, I just upgrade to 0.75 and last version of rns and it work for well.