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

error: no member named 'toCpp' on Android #448

Closed
4 of 5 tasks
baronha opened this issue Dec 25, 2024 · 3 comments · Fixed by #453
Closed
4 of 5 tasks

error: no member named 'toCpp' on Android #448

baronha opened this issue Dec 25, 2024 · 3 comments · Fixed by #453
Labels
nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase

Comments

@baronha
Copy link

baronha commented Dec 25, 2024

What's happening?

I don't know if this is valid? but when I declare a callback function in the config this in iOS works great. But building on Android has an error due to missing toCpp()
Screenshot 2024-12-25 at 10 31 12

Reproduceable Code

import { type HybridObject } from 'react-native-nitro-modules'

export type NitroPreviewConfig = {
  language: Language

  /**
   * Auto play video when open preview.
   *
   * @platform iOS, Android
   */
  videoAutoPlay?: boolean

  onLongPress?: (index: number) => void // --> THIS FUNC
}

export interface MultipleImagePicker
  extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
  openPreview(
    media: MediaPreview[],
    index: number,
    config: NitroPreviewConfig
  ): void
}

Relevant log output

/Users/mac/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/Users/mac/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DMultipleImagePicker_EXPORTS -I/Users/mac/project/react-native-multiple-image-picker/android/../nitrogen/generated/shared/c++ -I/Users/mac/project/react-native-multiple-image-picker/android/../nitrogen/generated/android/c++ -I/Users/mac/project/react-native-multiple-image-picker/android/../nitrogen/generated/android -I/Users/mac/project/react-native-multiple-image-picker/android/src/main/cpp -I/Users/mac/project/react-native-multiple-image-picker/android/../cpp -isystem /Users/mac/.gradle/caches/8.10.2/transforms/d31f451122629a882eaa4d4e39fe5824/transformed/fbjni-0.6.0/prefab/modules/fbjni/include -isystem /Users/mac/.gradle/caches/8.10.2/transforms/09e99889bdbc3a72b28a5d49d1ebcf4c/transformed/react-android-0.76.5-debug/prefab/modules/jsi/include -isystem /Users/mac/project/react-native-multiple-image-picker/example/node_modules/react-native-nitro-modules/android/build/headers/nitromodules -isystem /Users/mac/.gradle/caches/8.10.2/transforms/09e99889bdbc3a72b28a5d49d1ebcf4c/transformed/react-android-0.76.5-debug/prefab/modules/reactnative/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O2 -frtti -fexceptions -Wall -fstack-protector-all -fno-limit-debug-info  -fPIC -std=gnu++20 -MD -MT CMakeFiles/MultipleImagePicker.dir/Users/mac/project/react-native-multiple-image-picker/nitrogen/generated/android/c++/JHybridMultipleImagePickerSpec.cpp.o -MF CMakeFiles/MultipleImagePicker.dir/Users/mac/project/react-native-multiple-image-picker/nitrogen/generated/android/c++/JHybridMultipleImagePickerSpec.cpp.o.d -o CMakeFiles/MultipleImagePicker.dir/Users/mac/project/react-native-multiple-image-picker/nitrogen/generated/android/c++/JHybridMultipleImagePickerSpec.cpp.o -c /Users/mac/project/react-native-multiple-image-picker/nitrogen/generated/android/c++/JHybridMultipleImagePickerSpec.cpp

In file included from /Users/mac/project/react-native-multiple-image-picker/nitrogen/generated/android/c++/JHybridMultipleImagePickerSpec.cpp:93:
/Users/mac/project/react-native-multiple-image-picker/android/../nitrogen/generated/android/c++/JNitroPreviewConfig.hpp:46:66: error: no member named 'toCpp' in 'facebook::jni::HybridClass<margelo::nitro::multipleimagepicker::JFunc_void_double>::JavaPart'
        onLongPress != nullptr ? std::make_optional(onLongPress->toCpp()) : std::nullopt
                                                    ~~~~~~~~~~~~~^

Device

Emulator Android

Nitro Modules Version

0.20.1

Nitrogen Version

0.20.1

Can you reproduce this issue in the Nitro Example app here?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

@baronha baronha added the nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase label Dec 25, 2024
@mrousavy
Copy link
Owner

fix: #453

@mrousavy
Copy link
Owner

Unrelated to this being a bug, it is recommended to avoid objects if you can:
image

See Avoid unnecessary objects

@baronha
Copy link
Author

baronha commented Dec 30, 2024

Unrelated to this being a bug, it is recommended to avoid objects if you can: image

See Avoid unnecessary objects

Yah Sir. I followed your instructions to be safer. Thank you for listening to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants