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

[BUG] linux-arm64-java-matter-controller CHIPDeviceController-JNI.cpp:125: undefined reference to `AndroidChipPlatformJNI_OnLoad(JavaVM_*, void*)' #23726

Closed
lboue opened this issue Nov 22, 2022 · 3 comments
Assignees
Labels
android java Issues in java-matter-controller stale Stale issue or PR

Comments

@lboue
Copy link
Contributor

lboue commented Nov 22, 2022

Issue

Linux-arm64-java-matter-controller CHIPDeviceController-JNI.cpp:125: undefined reference to `AndroidChipPlatformJNI_OnLoad(JavaVM_, void)'

Reproduction steps

## Build linux-x64-java-matter-controller build

1. export ANDROID_HOME=/opt/android/sdk
3. ./scripts/build/build_examples.py --target linux-arm64-java-matter-controller build

Bug prevalence

Always

GitHub hash of the SDK that was being used

b450110

Platform

other

Platform Version(s)

N/A

Anything else?

Environment

  1. commit b450110
  2. Linux RPI4 5.15.0-1018-raspi #20-Ubuntu SMP PREEMPT Fri Nov 4 18:20:53 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
  3. Java : OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~22.04-b08)

Steps to reproduce

Download and install android SDK
wget -O /tmp/android-21.zip https://dl.google.com/android/repository/android-21_r02.zip
sudo mkdir -p /opt/android/sdk/platforms
cd /opt/android/sdk/platforms
sudo unzip /tmp/android-21.zip
sudo mv android-5.0.1 android-21
rm -f /tmp/android-21.zip
sudo chmod -R a+rX /opt/android/sdk
export ANDROID_HOME=/opt/android/sdk
Build controller
ubuntu@RPI4:~/connectedhomeip$ export JAVA_PATH=/usr/lib/jvm/java-8-openjdk-arm64

ubuntu@RPI4:~/connectedhomeip$ ./scripts/build/build_examples.py --target linux-arm64-java-matter-controller build
2022-11-22 19:49:15 INFO    Building targets: linux-arm64-java-matter-controller
2022-11-22 19:49:15 INFO    Preparing builder 'linux-arm64-java-matter-controller'
2022-11-22 19:49:15 INFO    Generating /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller
2022-11-22 19:49:15 INFO    Generating linux-arm64-java-matter-controller
2022-11-22 19:49:15 INFO    AUTO-DETECTING input matter IDL file.
2022-11-22 19:49:15 INFO    Generating compile_commands took 16ms
2022-11-22 19:49:15 INFO    Done. Made 166 targets from 118 files in 700ms
2022-11-22 19:49:15 INFO    Command ['gn', 'gen', '--check', '--fail-on-unused-args', '--export-compile-commands', '--root=/home/ubuntu/connectedhomeip/examples/java-matter-controller', '/home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller'] completed
2022-11-22 19:49:15 INFO    Setting up Java deps
2022-11-22 19:49:16 WARNING mkdir: cannot create directory ‘third_party/java_deps/artifacts’: File exists
2022-11-22 19:49:16 INFO    Command ['third_party/java_deps/set_up_java_deps.sh'] completed
2022-11-22 19:49:16 INFO    Copying Manifest.txt to /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller
2022-11-22 19:49:16 INFO    Command ['cp', '/home/ubuntu/connectedhomeip/examples/java-matter-controller/Manifest.txt', '/home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller'] completed
2022-11-22 19:49:16 INFO    Building /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller
2022-11-22 19:49:16 INFO    Building linux-arm64-java-matter-controller
2022-11-22 19:49:16 INFO    ninja: Entering directory `/home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller'
2022-11-22 19:49:16 INFO    [1/648] stamp obj/third_party/connectedhomeip/src/controller/data_model/data_model_codegen._metadata_path_list.txt.stamp
2022-11-22 19:49:16 INFO    [2/648] stamp obj/third_party/connectedhomeip/src/controller/data_model/java-jni-generate._metadata_path_list.txt.stamp
2022-11-22 19:49:17 INFO    [3/648] ACTION 

...

2022-11-22 20:12:31 INFO    [639/648] c++ obj/third_party/connectedhomeip/src/controller/java/zap-generated/libCHIPController.CHIPReadCallbacks.cpp.o
2022-11-22 20:13:29 INFO    [640/648] ld -shared lib/jni/libCHIPController.so
2022-11-22 20:13:29 INFO    FAILED: lib/jni/libCHIPController.so lib/jni/libCHIPController.map
2022-11-22 20:13:29 INFO    aarch64-linux-gnu-g++ -Wl,--gc-sections -O0 -fPIC -Werror -Wl,--fatal-warnings -Wl,-z,defs -fdiagnostics-color -Wl,--gc-sections -Wl,-Map,lib/jni/libCHIPController.map @lib/jni/libCHIPController.so.rsp -o lib/jni/libCHIPController.so -shared
2022-11-22 20:13:29 INFO    /usr/bin/ld: obj/third_party/connectedhomeip/src/controller/java/libCHIPController.AndroidDeviceControllerWrapper.cpp.o: in function `AndroidDeviceControllerWrapper::AllocateNew(JavaVM_*, _jobject*, unsigned long, unsigned long, chip::CATValues const&, chip::System::Layer*, chip::Inet::EndPointManager<chip::Inet::TCPEndPoint>*, chip::Inet::EndPointManager<chip::Inet::UDPEndPoint>*, std::unique_ptr<chip::Controller::AndroidOperationalCredentialsIssuer, std::default_delete<chip::Controller::AndroidOperationalCredentialsIssuer> >, _jobject*, _jbyteArray*, _jbyteArray*, _jbyteArray*, _jbyteArray*, unsigned short, unsigned short, unsigned short, bool, bool, bool, chip::ChipError*)':
2022-11-22 20:13:29 INFO    /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller/../../examples/java-matter-controller/third_party/connectedhomeip/src/controller/java/AndroidDeviceControllerWrapper.cpp:215: undefined reference to `CHIPP256KeypairBridge::SetDelegate(_jobject*)'
2022-11-22 20:13:29 INFO    /usr/bin/ld: obj/third_party/connectedhomeip/src/controller/java/libCHIPController.AndroidDeviceControllerWrapper.cpp.o: in function `CHIPP256KeypairBridge::CHIPP256KeypairBridge()':
2022-11-22 20:13:29 INFO    /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller/../../examples/java-matter-controller/third_party/connectedhomeip/src/platform/android/CHIPP256KeypairBridge.h:34: undefined reference to `vtable for CHIPP256KeypairBridge'
2022-11-22 20:13:29 INFO    /usr/bin/ld: /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller/../../examples/java-matter-controller/third_party/connectedhomeip/src/platform/android/CHIPP256KeypairBridge.h:34: undefined reference to `vtable for CHIPP256KeypairBridge'
2022-11-22 20:13:29 INFO    /usr/bin/ld: obj/third_party/connectedhomeip/src/controller/java/libCHIPController.CHIPDeviceController-JNI.cpp.o: in function `JNI_OnLoad':
2022-11-22 20:13:29 INFO    /home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller/../../examples/java-matter-controller/third_party/connectedhomeip/src/controller/java/CHIPDeviceController-JNI.cpp:125: undefined reference to `AndroidChipPlatformJNI_OnLoad(JavaVM_*, void*)'
2022-11-22 20:13:29 INFO    collect2: error: ld returned 1 exit status
2022-11-22 20:13:29 INFO    ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/ubuntu/connectedhomeip/./scripts/build/build_examples.py", line 202, in <module>
    main()
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    rv.append(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/connectedhomeip/.environment/pigweed-venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/connectedhomeip/./scripts/build/build_examples.py", line 192, in cmd_build
    context.obj.Build()
  File "/home/ubuntu/connectedhomeip/scripts/build/build/__init__.py", line 71, in Build
    builder.build()
  File "/home/ubuntu/connectedhomeip/scripts/build/builders/builder.py", line 95, in build
    self._build()
  File "/home/ubuntu/connectedhomeip/scripts/build/builders/gn.py", line 105, in _build
    self._Execute(cmd, title='Building ' + self.identifier)
  File "/home/ubuntu/connectedhomeip/scripts/build/builders/builder.py", line 100, in _Execute
    self._runner.Run(cmdarray, title=title)
  File "/home/ubuntu/connectedhomeip/scripts/build/runner/shell.py", line 73, in Run
    raise Exception('Command %r failed: %d' % (cmd, code))
Exception: Command ['ninja', '-C', '/home/ubuntu/connectedhomeip/out/linux-arm64-java-matter-controller'] failed: 1
@bzbarsky-apple bzbarsky-apple added android java Issues in java-matter-controller labels Nov 29, 2022
@yunhanw-google
Copy link
Contributor

we don't support chip matter controller app in android, we only support it in linux environment., try the below, thanks

https://github.com/project-chip/connectedhomeip/tree/master/examples/java-matter-controller, which can run java controller in linux environment to test accessary.

some instructions are as below.
-- Build
docker run -it -v /workspace/connectedhomeip:/connectedhomeip connectedhomeip/chip-build:0.6.06
git config --global --add safe.directory /connectedhomeip
git config --global --add safe.directory /connectedhomeip/third_party/pigweed/repo
export JAVA_PATH=/usr/lib/jvm/java-8-openjdk-amd64/
source scripts/bootstrap.sh
./scripts/build/build_examples.py --target linux-x64-java-matter-controller build
./scripts/build/build_examples.py --target linux-x64-all-clusters build

--In Terminal A
docker exec -it c20375aeb713 bash
rm -rf /tmp/chip* & ./out/linux-x64-all-clusters/chip-all-clusters-app

--In terminal B
docker exec -it c20375aeb713 bash
java -verbose:jni -Xcheck:jni -jar -Djava.library.path=out/linux-x64-java-matter-controller/lib/jni out/linux-x64-java-matter-controller/bin/java-matter-controller pairing onnetwork-long 1 20202021 3840 1000

@stale
Copy link

stale bot commented Aug 11, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Aug 11, 2023
@stale
Copy link

stale bot commented Oct 15, 2023

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android java Issues in java-matter-controller stale Stale issue or PR
Projects
No open projects
Status: Todo
Development

No branches or pull requests

3 participants