Open redorav opened 2 weeks ago
Are you aware of https://github.com/polymonster/premake-android-studio?
It can generate Gradle project for Android.
Hmm does this work with visual studio? I'll try it out
Hmm does this work with visual studio? I'll try it out
I have not tried the generated Gradle project with VS yet, but AFAIK it's a "standard" Gradle Android project so it may work fine.
Hi, I generated the project but it's clearly not intended for use with Visual Studio, it still reports as being Win32, doesn't know anything about Gradle, etc. I think the intention there is for people who already use Premake to use the Android Studio IDE instead for Android development
Yep, I think it should be possible to re-use the same generated Gradle project for VS though right? Presumably some modifications need to be made to the Premake-generated VS project files to include them somehow. Need to check a VS Android/Gradle sample hello world project to figure out what is needed.
Right I see what you mean now, I'll investigate to see what it is they're generating and how it works. One thing I noticed is that Android Studio is a lot more dynamic about fixing configuration errors than Visual Studio is, it starts downloading and updating plugins and updates automatically without me really knowing what's going on. Android is a difficult ecosystem
The VS hello world is meant to work out of the box but I've noticed that any local modifications to e.g. the Java JDK or the Android SDK throw it off quite a bit, perhaps I just need to understand this a bit better. In any case, an extension to the current core plugin is probably necessary
Can anyone with more Android experience know what's up with the Android situation on VS2022? Does the Premake backend need to change to accommodate Gradle projects?
Android MDD (the MSBuild integration) is pretty much abandonware. Microsoft is only interested in .NET, and they didn't keep up with NDK releases well enough. The last version with a working Ant/MDD is Visual Studio 2022 v17.2—that's an out-of-date version, but you can install it side by side. It's in the LTSC branch. The last version of NDK that works well with it is R22, but you can also use R23 with a few .props
tweaks in the VS installation folder.
Have you had this experience with it as well then? For my immediate purposes I rooted a spare phone I had and went ahead with VS2019 and the Ant-based workflow, I just need it for the unit tests of a library I have. I wasn't able to get the gradle version going yet, I think I was getting relatively close though, the library was being packed into the apk but I wasn't able to run the native activity. The debugger was crashing too but I think it's because it wasn't bundling the gdb library as well (which I can see inside the ant-based one). Overall it does look like they mostly care about .NET and the Xamarin stuff so I may be out of luck. Android Studio was a bit of a mess too, I couldn't get it to compile in a reasonable timeframe, looks like you need to understand Gradle properly before getting anything out of it
@redorav The GDB debugger included in Visual Studio didn't work for Android 14 the last time I tried. I have several older devices running Android 8, 11, and 13, and they work fine with these. It seems to be related to scoped storage restrictions that LLDB, the newer debugger, has fixed. If Microsoft's native Android integration were open-source, I'd attempt to fix it myself.
You also mentioned running unit tests on an Android phone for a library. If you don't need to run an Activity, you can compile the test runner as a standalone binary, copy it to /data/local/tmp, apply chmod +x, and run it there.
Regarding Android Studio, I have a minimal project that uses Gradle with XMake. Maybe give this a try? example-xmake-android-project
Also about Gradle being slow, to compile faster, you can enable these Gradle flags:
org.gradle.jvmargs=-Xmx3g
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
@ifarbod interesting find about the Visual Studio debugger not being compatible.
As for my library, I do run a native activity as my project is in C++, and I've been able to debug and put breakpoints all along in the Ant-based version of this, which is why I'd like this Gradle-based thing to work properly :/
I've not tried xmake but as far as I can tell it bypasses all the Visual Studio project properties and does its own thing? I might take a deeper look, are you experienced with it? So far I really like Premake because it integrates with the tools instead of doing its own thing via command lines
@redorav If you want the Gradle-based version to work on your rooted (preferably SELinux-permissive) phone, you can try bundling the gdbserver
manually in the generated APK, take the binary out and place it in jniLibs
or so.
As for XMake,
Hi,
I've been using the Android integration in Premake for a while now for my projects. The Android integration creates what VS used to call a "Native Activity" and with a bit of glue code it worked fine. Fast forward a few months and MS has removed the native activity completely as everything that was ant-based is deprecated, and while compiling the native activity works (in VS2019) you cannot install it anymore because the way applications used to be installed in debug mode (copying to the tmp folder and running the apk) doesn't work now due to permissions.
The only way to create an application in VS2022 these days is using Gradle, but I've struggled to make sense of it and even a basic clean project doesn't compile, it gives all sorts of Java, Gradle and combinations of those errors. There is very little information out there regarding this change.
Can anyone with more Android experience know what's up with the Android situation on VS2022? Does the Premake backend need to change to accommodate Gradle projects?
I've found out in the meantime that Google supplies an official Android GDK for C/C++ projects. Would it make sense to integrate that as well as part of core?
Many thanks