Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build fail on Android, cast float to double - support React Native 0.72 #270

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

LeeMoonki
Copy link
Contributor

Summary

Hello, thank you very much for creating such a great open-source project.
I installed version 2.9.1 to use react-native-unistyles. However, I encountered the following error while building the Android app.

[1/7] Building CXX object CMakeFiles/unistyles.dir/src/main/cxx/helpers.cpp.o
[2/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesRuntime.cpp.o
[3/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesModel.cpp.o
[4/7] Building CXX object CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp.o
FAILED: CMakeFiles/unistyles.dir/.../node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp.o

.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1102:43: error: no matching function for call to 'kindOf'
  /* implicit */ Value(T&& other) : Value(kindOf(other)) {
                                          ^~~~~~

error: static_assert failed due to requirement 'std::is_base_of<facebook::jsi::Symbol, float>::value || std::is_base_of<facebook::jsi::BigInt, float>::value || std::is_base_of<facebook::jsi::String, float>::value || std::is_base_of<facebook::jsi::Object, float>::value' "Value cannot be implicitly move-constructed from this type"
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1102:43: error: no matching function for call to 'kindOf'
/node_modules/react-native-unistyles/cxx/UnistylesImpl.cpp:237:12: note: in instantiation of function template specialization 'facebook::jsi::Value::Value<float>' requested here
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1350:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::Symbol' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1353:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::BigInt' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1356:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::String' for 1st argument
.gradle/caches/transforms-3/ef2d7697779c544a76e341d3d27be809/transformed/jetified-react-android-0.72.6-debug/prefab/modules/jsi/include/jsi/jsi.h:1359:30: note: candidate function not viable: no known conversion from 'float' to 'const facebook::jsi::Object' for 1st argument

So, I successfully built the project after modifying react-native-unistyles/cxx/UnistylesImpl.cpp as requested. I'm not sure why the implicit conversion fails, but there are no functional issues. I’m submitting this PR because other users might encounter the same problem.

Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-unistyles-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 6:05am

@LeeMoonki LeeMoonki changed the title fix: cast float to double fix: build fail on Android, cast float to double Aug 28, 2024
@jpudysz
Copy link
Owner

jpudysz commented Aug 28, 2024

That's interesting!
What's your RN version?

@LeeMoonki
Copy link
Contributor Author

@jpudysz The version of react-native is 0.72.6. However, since the relevant code in the latest version of react-native is identical to that in version 0.72.6, I believe that the issue could also occur in the current version of React Native.

@jpudysz
Copy link
Owner

jpudysz commented Aug 28, 2024

Were you able to compile it with 0.72? 😮
I thought that the minimal version is 0.73!

If that's the only change to compile I will accept this PR

@LeeMoonki
Copy link
Contributor Author

@jpudysz When we initially created the app we're currently managing in-house, the version was 0.72, and there hasn't been any version change since then. I've confirmed that there won't be any issues with compilation as long as the requested changes are made. 🤓

@jpudysz
Copy link
Owner

jpudysz commented Aug 28, 2024

Cool, thank you for the PR!

@jpudysz jpudysz changed the title fix: build fail on Android, cast float to double fix: build fail on Android, cast float to double - support React Native 0.72 Aug 28, 2024
@jpudysz jpudysz merged commit 8370345 into jpudysz:main Aug 28, 2024
3 checks passed
@LeeMoonki
Copy link
Contributor Author

@jpudysz I should be the one thanking you for the quick response and implementation! 😁

@jpudysz
Copy link
Owner

jpudysz commented Aug 28, 2024

Will release it later this week with some other minor improvements!

For now please keep your local changes 🙏

@LeeMoonki
Copy link
Contributor Author

Will release it later this week with some other minor improvements!

For now please keep your local changes 🙏

ok ! thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants