examples: Use single up-to-date android example#23491
examples: Use single up-to-date android example#23491leomeinel wants to merge 8 commits intobevyengine:mainfrom
Conversation
8d26f08 to
b424cfa
Compare
b424cfa to
a3ffcd6
Compare
a3ffcd6 to
bdbace9
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
3ee40f5 to
9ad8fb2
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
7007739 to
d6ac06a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
|
glad to see updates on android! I just followed the java one before when I was making that update though, I'm favor to kotlin too for libc++_shared, iirc it's required for also about |
This comment was marked as resolved.
This comment was marked as resolved.
|
I believe |
|
|
||
| - name: Build app for Android | ||
| run: cd examples/mobile/android_example && chmod +x gradlew && ./gradlew build | ||
| run: cd ./examples/mobile/android && chmod +x ./gradlew && ./gradlew build |
There was a problem hiding this comment.
nit: chmod +x is not needed. I can confirm the permissions of gradlew file you commited is 755 on linux.
There was a problem hiding this comment.
Thank you for the review. I'll add a fixup commit that omits it. I just forgot to not include it 👍
If anyone wants the file to have 644 permissions instead, I can alternatively just do that.
This comment was marked as resolved.
This comment was marked as resolved.
63ea3f0 to
65e6a23
Compare
65e6a23 to
e4b4b72
Compare
leomeinel
left a comment
There was a problem hiding this comment.
Tested in Android studio emulator and working.
I don't agree with this. The differences between examples are meaningful and should be shown somewhere. I would prefer better documentation than just removing them |
I could add a diff of |
|
Both regressions are now unrelated to this. |
There was a problem hiding this comment.
I think it's a good cleanup and tend to keep only one example (the native activity example is almost a duplicate). Actually I've never tested the other two examples. For users who want to try other approaches, android-activity and cargo-apk repositories have some examples, too. They might be worth mentioning but we lack testing.
Additionally, this PR will resolve the 16kb compatibility issue (See the screenshots of Android 16.0 / Samsung Galaxy S26 in https://bevyengine.github.io/bevy-example-runner). Already fixed since rodio update?
Objective - Only use a single modern and better documented android example - Fix bevyengine#10945 - Fix bevyengine#17122 Problems with current examples - We are currently using deprecated functions like for example [setSystemUiVisibility(int)](https://developer.android.com/reference/android/view/View#setSystemUiVisibility(int)). - Most Android dependencies are very out of date. - Kotlin is the [preffered language](https://developer.android.com/kotlin/first) for Android and we should migrate the examples to it. - Most of the code in the examples is not inherently clear and there are very few comments especially in the build scripts. - We should only have a single Android example using `games-activity` and `cargo-ndk`. It is confusing and unnecessary to do it any other way in my opinion. - The crash from bevyengine#10945 is fixed by migrating to `games-activity` 4. Before this PR, we were using `games-activity` 2. bevyengine#17122 is apparently also fixed because of this. Solution - Replace all android examples with `./examples/mobile/android` - Update dependencies in `libs.versions.toml` - Add `gradle-daemon-jvm.properties` generated with `./gradlew updateDaemonJvm` - Update gradle wrapper - Migrate everything to kotlin/kotlin build scripts - Use supported functions instead of deprecated ones - Move `/assets/ic_launcher.png` to `/examples/mobile/android/app/src/main/res/mipmap/ic_launcher.png` because that is where it is [meant to be stored](https://developer.android.com/guide/topics/resources/providing-resources). - Use `--link-libcxx-shared` flag for `cargo-ndk` in `examples/README.md` - Use `targetSdk = 36` and `compileSdk = 36` and explain in `examples/README.md`
I assumed at first that the table was under the About `cargo-apk` heading for Android, therefore I removed it at first. Now I moved it directly under the Android heading which makes a lot more sense in my opinion. The same has been done with the ios table for consistency. Additionally this uses mobile as the example identifier since the mentioned file is not platform specific in the table.
1cee23a to
f85deb5
Compare
f85deb5 to
9d79173
Compare
Objective
Problems with current examples
games-activityandcargo-ndk. It is confusing and unnecessary to do it any other way in my opinion.Solution
./examples/mobile/androidlibs.versions.tomlgradle-daemon-jvm.propertiesgenerated with./gradlew updateDaemonJvm./assets/android-res/mipmap-mdpi/ic_launcher.pngto/examples/mobile/android/app/src/main/res/mipmap/ic_launcher.pngbecause that is where it is located by default.targetSdk = 36andcompileSdk = 36and explain inexamples/README.mdTesting
This currently builds successfully with
cargo-ndkwith the following commands:cd ./examples/mobile cargo ndk build -t aarch64-linux-android -o ./android/app/src/main/jniLibsAfterwards you can build it with gradle like this or just use Android Studio:
cd ./android ./gradlew buildCurrent problems
Unrelated regression
Regression from #23551
Crashes if built without
--releaseflag onx86_64. This seems to be only related to the change in android-activity version.I have added a note to README.md for this.
Related