Status Update
Comments
ch...@google.com <ch...@google.com>
ar...@google.com <ar...@google.com> #2
there are some image for help
ar...@google.com <ar...@google.com> #3
hello?
ar...@google.com <ar...@google.com> #4
ar...@google.com <ar...@google.com> #5
For the reference, see @gfan CLs from this issue:
ar...@google.com <ar...@google.com>
ar...@google.com <ar...@google.com>
bk...@google.com <bk...@google.com>
ar...@google.com <ar...@google.com>
ap...@google.com <ap...@google.com> #6
Branch: main
commit 7ff99f881ad9a9a284b1b27610bc2f730b8b8c3f
Author: Artyom Palvelev <artyompp@google.com>
Date: Thu Sep 12 13:54:14 2024
add cpp files into prefabs for GameActivity/GameTextInput
This change removes null.cpp practice and instead puts all cpp files
into correponding libraries of GameActivity and GameTextInput. Both
shared and static libraries should work.
It's now discouraged to do something like include <GameActivity.cpp>.
Instead, you shoudld include the corresponding library into your
CMakeLists.txt file, for example:
target_link_libraries(${CMAKE_PROJECT_NAME} game-activity::game-activity_static)
Test: compile and run AGDKTunnel, BouncyBall, game_text_input_testbed
Bug: 358918880
Change-Id: I3ae5eff462a537f94a74700ab8a9c3e2be7f58d5
M game-activity/CMakeLists.txt
D game-activity/null.cpp
M game-activity/prefab-src/modules/game-activity/include/game-activity/GameActivity.h
D game-activity/prefab-src/modules/game-activity/include/game-text-input/gamecommon.h
D game-activity/prefab-src/modules/game-activity/include/game-text-input/gametextinput.cpp
A game-activity/prefab-src/modules/game-activity/src/common/system_utils.cpp
M game-activity/prefab-src/modules/game-activity/src/game-activity/GameActivity.cpp
M game-activity/prefab-src/modules/game-activity/src/game-activity/GameActivityEvents.cpp
M game-activity/prefab-src/modules/game-activity/src/game-activity/GameActivityEvents_internal.h
M game-activity/prefab-src/modules/game-activity/src/game-activity/native_app_glue/android_native_app_glue.c
A game-activity/prefab-src/modules/game-activity/src/game-text-input/gametextinput.cpp
A game-activity/prefab-src/modules/game-activity/src/game-text-input/gametextinput.h
M game-activity/prefab-src/prefab.json
M game-text-input/CMakeLists.txt
D game-text-input/null.cpp
D game-text-input/prefab-src/modules/game-text-input/include/game-text-input/gamecommon.h
M game-text-input/prefab-src/modules/game-text-input/include/game-text-input/gametextinput.h
M game-text-input/prefab-src/modules/game-text-input/module.json
M game-text-input/prefab-src/modules/game-text-input/src/game-text-input/gametextinput.cpp
M game-text-input/prefab-src/prefab.json
M game-text-input/src/androidTest/res/layout/activity_main.xml
M samples/game_text_input/game_text_input_testbed/app/CMakeLists.txt
M samples/game_text_input/game_text_input_testbed/app/build.gradle
M samples/game_text_input/game_text_input_testbed/app/src/main/cpp/game-input.cpp
ar...@google.com <ar...@google.com>
ar...@google.com <ar...@google.com> #8
Yes these two issues are connected.
in...@gmail.com <in...@gmail.com> #9
So, basically it happened to me because I had one test project derived by a sample and I made another one from the new->game activity on Android Studio. So one was with 3.0.5 explicitly (gradle with groovy) and the other one was implicitly with 1.2.2 (from implementation(libs.androidx.games.activity)). So when I tried to bring the code regarding Game Activity, I got the error. I figured it out when I found another test I had and the libs.versions.toml had the 3.0.5 instead of 1.2.2. So the differences were in the headers,
for 1.2.2
#include <game-activity/GameActivity.cpp>
#include <game-text-input/gametextinput.cpp>
#include <game-activity/native_app_glue/android_native_app_glue.c>
and for 3.0.5
#include "game-activity/native_app_glue/android_native_app_glue.h"
I had then to add on the CMakelists.txt:
# Export GameActivity_onCreate(),
# Refer to: https://github.com/android-ndk/ndk/issues/381.
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -u Java_com_google_androidgamesdk_GameActivity_initializeNativeCode")
and use the:
game-activity::game-activity_static
this made going from 1.2.2 to 3.0.5 possible.
note that instead (it's another bug i guess):
game-activity::game-activity
gave me an error or a function not present to the linker (!!):
ld.lld: error: undefined symbol: GameActivityMotionEvent_destroy
>>> referenced by android_native_app_glue.c:541 (/home/bloom/.gradle/caches/8.9/transforms/b3e4b38b898120fddfba2ec14de1fef1/transformed/games-activity-3.0.5/prefab/modules/game-activity/include/game-activity/native_app_glue/android_native_app_glue.c:541)
>>> CMakeFiles/hello_cloudxr_native.dir/src/main/cpp/main.cpp.o:(android_app_clear_motion_events)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
and copy pasting that function from the source to my code bypassed the error. The function:
extern "C" void GameActivityMotionEvent_destroy(
GameActivityMotionEvent *c_event) {
delete c_event->historicalAxisValues;
delete c_event->historicalEventTimesMillis;
delete c_event->historicalEventTimesNanos;
}
I would suggest making the migration steps clearer to the user, I got them right a bit by luck.
Hope it helps.
ar...@google.com <ar...@google.com> #10
Thanks for this work. This indeed fixes the compilation. I guess we have to wait for GameActivity 4.0.0 stable release in order to include this fix, as I don't think it's reasonable to include unstable versions (current version is 4.0.0-alpha01).
ar...@google.com <ar...@google.com> #11
However, I'm still puzzled by the lack of GameActivityMotionEvent_destroy
. Does this symbol only exist in the static library but not in the dynamic one?
in...@gmail.com <in...@gmail.com> #12
Yes, that happened on my project, that symbol is not defined if remove the _static suffix from game-activity::game-activity in the CMakeLists.txt file. I didn't try again but I tried to reproduce with your sample game_controller in games-samples/agdk, Only change, I had to update the gradle used to 8.9 due to my JDK version. Removing the _static gave the following errors:
for game activity 2.0.2 (original sample version)
ld.lld: error: undefined symbol: GameActivity_setWindowFlags
>>> referenced by native_engine.cpp:195 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:195)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::GameLoop())
ld.lld: error: undefined symbol: GameActivity_getWindowInsets
>>> referenced by native_engine.cpp:355 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:355)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::UpdateSystemBarOffset())
ld.lld: error: undefined symbol: android_app_swap_input_buffers
>>> referenced by native_engine.cpp:366 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:366)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: android_app_clear_key_events
>>> referenced by native_engine.cpp:375 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:375)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: android_app_clear_motion_events
>>> referenced by native_engine.cpp:386 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:386)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: GameActivityPointerAxes_enableAxis
>>> referenced by native_engine.cpp:401 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:401)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::CheckForNewAxis())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
C++ build system [build] failed while executing:
/home/bloom/Android/Sdk/cmake/3.22.1/bin/ninja \
-C \
/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/.cxx/Debug/1r6c1j55/arm64-v8a \
game
from /home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app
for game activity 3.0.5 (latest reported by Android Studio)
ld.lld: error: undefined symbol: GameActivity_setWindowFlags
>>> referenced by native_engine.cpp:195 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:195)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::GameLoop())
ld.lld: error: undefined symbol: GameActivity_getWindowInsets
>>> referenced by native_engine.cpp:355 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:355)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::UpdateSystemBarOffset())
ld.lld: error: undefined symbol: android_app_swap_input_buffers
>>> referenced by native_engine.cpp:366 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:366)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: android_app_clear_key_events
>>> referenced by native_engine.cpp:375 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:375)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: android_app_clear_motion_events
>>> referenced by native_engine.cpp:386 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:386)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::HandleGameActivityInput())
ld.lld: error: undefined symbol: GameActivityPointerAxes_enableAxis
>>> referenced by native_engine.cpp:401 (/home/bloom/sw_develop/Android/Samples/games-samples/agdk/game_controller/app/src/main/cpp/native_engine.cpp:401)
>>> CMakeFiles/game.dir/native_engine.cpp.o:(NativeEngine::CheckForNewAxis())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
So I guess a good starting point would be try with and without _static on the AGDK samples. As I understand the suggested library version is the static one, so it may be that this kind of bug/behaviour is already known?
ar...@google.com <ar...@google.com> #13
Blocked by
Description
Create a default project:
File → New → New Project → Game Activity (C++) → Next
In build.gradle.kts (:app), change version of androidx.games:games-activity to 3.0.5 (or anything else later than 1.2.2).
/opt/android-sdk-update-manager/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=x86_64-none-linux-android30 --sysroot=/opt/android-sdk-update-manager/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dmyapplication_EXPORTS -isystem /home/.gradle/caches/transforms-3/e197fbe71d271970eb52f1c99e8128de/transformed/games-activity-3.0.5/prefab/modules/game-activity/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/myapplication.dir/main.cpp.o -MF CMakeFiles/myapplication.dir/main.cpp.o.d -o CMakeFiles/myapplication.dir/main.cpp.o -c /home/android/MyApplication/app/src/main/cpp/main.cpp
In file included from /home/android/MyApplication/app/src/main/cpp/main.cpp:6:
/home/.gradle/caches/transforms-3/e197fbe71d271970eb52f1c99e8128de/transformed/games-activity-3.0.5/prefab/modules/game-activity/include/game-activity/GameActivity.cpp:43:10: fatal error: 'system_utils.h' file not found
#include "system_utils.h"
^~~~~~~~~~~~~~~~
Component used: androidx.games:games-activity
Version used: 3.0.5
Devices/Android versions reproduced on: Build error, so can't reproduce on any device