SDL2 with android and the new anrdoid studio |
SDL2 with android and the new anrdoid studio |
Michael Labbé
Guest
|
When I last checked in six months ago, gradle and android studio were not up to the task of working on mostly native android projects.
I have had the highest productivity working with the NVidia Tegra tools, an NVidia Shield and Visual Studio 2013 or 2012 (doesn't matter which). I then deploy my sdk project for more architectures using ndk-build and ant. Michael Labbé
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL2 with android and the new anrdoid studio |
Owen Alanzo Hogarth
Guest
|
I didn't even think about NVidia Tegra tools, I don't have a pc so the visual studio workflow is a non starter for me. I will look into the NVidia tools and see if I can get that to work. Thanks for the tip.
On Fri, Aug 21, 2015 at 3:56 AM, Michael Labbé wrote:
|
|||||||||||||||
|
SDL2 with android and the new anrdoid studio |
gormlai
|
I contacted one Google's developer relations people, and unfortunately Android Studio still doesn't support subprojects which build libraries. I personally thought it better to wait, than to fudge it.
On 20/08/2015 21:23, Owen Alanzo Hogarth wrote:
|
|||||||||||||||||||
|
SDL2 with android and the new anrdoid studio |
Eric Wing
Guest
|
On 8/20/15, Owen Alanzo Hogarth wrote:
Yes, kind of... I build SDL into library conforming to the Android NDK_MODULE convention. (I've posted about this before on the list.) At this point, it doesn't really matter what you use for the final mile for your app, though I moved to Android Studio because it was clear Google was dropping Eclipse/Ant and installing Ant dependencies started becoming an ordeal for me on latest Mac. At the time, it had no NDK support, so I hacked up my own Groovy/Gradle scripts to the right thing for the NDK half of the build. I'm actually using CMake for everything which makes it easy to support a ton of platforms with a single build description, so my scripts call out to CMake coordinate between the NDK/SDK halves. Then Android Studio does the rest of its normal stuff for the SDK, signing, and packaging. -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL2 with android and the new anrdoid studio |
Martin Gerhardy
Guest
|
sorry for offtopic: do you use an android toolchain or do you use ndkbuild and use cmake just to generate the Andeoid.mk files? do you habe a link? my current cmake solution can be found in the link in my signature
http://www.caveproductions.org
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
SDL2 with android and the new anrdoid studio |
Owen Alanzo Hogarth
Guest
|
@Eric
I currently build SDL with cmake as well, I haven't really used much of android studio since I mostly do command line builds and what not. Is it fairly straight forward to have gradle work nicely with cmake? On Fri, Aug 21, 2015 at 9:19 AM, Eric Wing wrote:
|
|||||||||||||||
|
SparkyNZ
|
I just hope somebody posts a blog/tutorial soon describing how to setup SDL with Android Studio. Thankfully I'm not starting my Android port yet..
|
|||||||||||
|
scanner_darkly
|
I used the same setup that you would for Eclipse for the most part. I'm using the latest Android Studio (1.3.2) with NDK r10e. Here's my app.grade:
And I had to add a "gradle.properties" file in the same directory as "build.gradle" file that had:
And make sure to add this to Application.mk:
And then I run "ndk-build" from the Android Studio terminal from the JNI directory. |
|||||||||||||||||||
|
SparkyNZ
|
Thanks scanner! I have Eclipse/NDK set up on a Mac and I'd like to set Android Studio up on Windows.. That means I'll probably have to set up Eclipse etc first on my Win machine then try what you have posted. Thanks a lot though - I hope you don't mind further questions. |
|||||||||||||
|
scanner_darkly
|
No problem. I used this YouTube video as a reference: https://www.youtube.com/watch?v=5_we0KZqDlU (although it uses Eclipse)
And I used this StackOverflow post for help with AS ndk: http://stackoverflow.com/questions/16667903/android-studio-gradle-and-ndk |
|||||||||||
|
SparkyNZ
|
Hi Scanner. Would you like to upload/make publicly available a simple SDL "Hello World" project for Android Studio please? |
|||||||||||||
|
scanner_darkly
|
I created a sample project that uses SDL2, GLM, and OpenGL ES 3 (although you can comment out the GLM and OpenGL stuff if desired). Let me know if you have any questions, I added details in the README of the project. Link: https://gitlab.com/scannerdarkly/hello-sdl-android |
|||||||||||||
|
SparkyNZ
|
Thanks Scanner. I am using Windows (guess you're using Mac/Linux?) and I'm having some problems with ndk-build.
W:\hello-sdl-android\android-project\app\src\main\jni>ndk-build make.exe: *** No rule to make target `W:/hello-sdl-android/android-project/app/s rc/main/jni/src/../SDL2/src/main/android/SDL_android_main.c', needed by `W:/hell o-sdl-android/android-project/app/src/main/obj/local/armeabi/objs/main/__/SDL2/s rc/main/android/SDL_android_main.o'. Stop. I suspect that the SDL2 paths above are wrong. My SDL2 content is in folder W:\SDL2. I modified the SDL2 and GLM link variables to point to these locations (and also declared some environment variables) but its still not happy. Other than Android.mk and Application.mk, is there another .mk file which I will need to modify.. or will I have to change another type of file? Gradle and Android Studio are new to me so I'm a little lost. Thanks. |
|||||||||||
|
SparkyNZ
|
I found that I needed to change the SDL_PATH and GLM_PATH in the jni\src\Android.mk to get it to start compiling.
Now I have the following (linker?) problem:
The Android.mk only seems to include one SDL source file:
Is SDL_android_main.c supposed to include SDL_android.c somehow? This is where SDL_Android_Init() is defined. |
|||||||||||||||
|
SparkyNZ
|
Actually.. I am wondering if putting SDL and GLM into folders on my W:\ is what is causing my problem?
Since you have used 'ln' to link the SDL and GLM folders under your test project.. then your SDL and GLM folders would "appear" to be sub-folders of your project folder wouldn't they? Since there is no 'ln' command in Windows, perhaps I need to make local copies of the SDL and GLM source under the test app project folder? |
|||||||||||
|
SparkyNZ
|
I made copies of SDL2 and GLM content in the folders where you had the ln links. ndk-build works fine now - I can build the application via command-line.
My only questions now are: 1) Can Android Studio build/call the ndk-build on my behalf? (ie can I build from within the IDE) 2) How do you run the application? My Samsung device installed but I cannot get a 'select device' dialog to appear. When I select "Run" I get a drop-box with "Edit Configurations" displayed. Do I *need* to create a new configuration or just use the "Defaults"? Under "Android Application" I have tried both "Show chooser dialog" and "Use USB device" but neither are doing anything when I click on "Run'. I have used this device before for simple Hello World java test apps - but only with Eclipse on a different laptop. Would you recommend I try getting a simple Java test app to work before trying to get an NDK app working? |
|||||||||||
|
scanner_darkly
|
Hey, glad to see you have parts of it working now. I think my example might have been a bit overkill using OpenGL and GLM but it looks like you got that working too.
In regards to the questions...
I think so but I prefer to execute it manually. According to this Stack Overflow post you can have Gradle take care of the NDK http://stackoverflow.com/questions/16667903/android-studio-gradle-and-ndk
You shouldn't have to modify any of these modifications at all. You do need to setup a USB driver (usually) for your device and your Operating System to connect, and then Android Studio should take care of the rest. Try going to "Build -> Make Project" in Android Studio. Also right below that where the little Android icon is there should be a drop-down menu, switch it from "Edit Configurations" to "App". If there is no app option then there's a problem!
Definitely. Create a new "Hello World" Android Studio Java project and make sure that you can run that on your device first before using the SDL project. Let me know how things go! |
|||||||||||||||||
|
SparkyNZ
|
Thanks again - definitely making progress here. I just repeated the same process on my other PC. I definitely have a driver issue to sort out on my other laptop. On this PC it runs.. and crashes.. I had to lower the SDK versions from 18 to 15 (API 17 may have been OK - my devices has Android 4.2.2) but I noticed in the logcat an error stating that "libGLESv3.so" could not be found. (See below). Thanks for the Gradle/NDK link - I'll be sure to check that out once I get this demo app to work. Do have any idea what could be causing the libGLESv3.so issue? Does the project need to be tweaked to use GLESv2 or something?
|
|||||||||||||||
|
SparkyNZ
|
Just a quick update - I tried my Samsung S4 instead of my Samsung 8" tablet - it works fine on the S4! So the question is - is this an SDL2 issue, a configuration issue or an application/build issue? |
|||||||||||||
|
SparkyNZ
|
http://delphigl.de/glcapsviewer/gles_generatereport.php?reportID=384
Ok. My tablet api is 17. If I try to build your project with 17 instead of 18, it cannot include the GLES3 header files. I do want to do basic GLSL .. nothing special. So by the looks of things I will have to drop to GLES2? The below link claims my tablet supports GLES3.. but thats way over my head. Above link I mean. Hard to type on tablets. |
|||||||||||
|
SparkyNZ
|
OpenGL ES2 appears to work on my device with API 17.
Only one (last?) problem to resolve - SDL related:
I commented out the VAO (OpenGL ES3) lines in your sample app. The app runs but gives me a black screen and nothing else. |
|||||||||||||
|
SparkyNZ
|
Thanks heaps for this, Scanner! I may have to upload a copy of my derived project. I have managed to get it to work with OpenGL ES2 on both my Samsung devices with API 17. I replaced the code so that it just draws a red triangle but thats more than enough to get me started. I can finally move my SDL1.x app from Windows over to Android and iOS.
|
|||||||||||
|
scanner_darkly
|
Awesome! Yeah, GLES 3 requires API 18, but is fully compatible with GLES 2. |
|||||||||||||
|
SparkyNZ
|
If it will help anybody, here's a link to an Android Studio SDL2 project that will build under Android Studio itself (you don't need to run ndk-build from the command line). It does include the SDL2 source itself - I had some trouble getting the 'exclude' command to work at first so I have deleted all of the non-Android folders in the archive. I need to investigate more on whether or not static libraries will work with the experimental gradle plugin - surely they must..
This is a mutates version of Scanner's project - it just draws a red triangle, uses GLES2 and it runs on both of my Samsung devices. Hope it helps - as of today, Android Studio still isn't ready to support NDK and SDL2 in my opinion. Hopefully it will be complete soon. http://www.mediafire.com/download/3i2175onr9gchb7/hello-sdl-android_RUNS.zip I've tested this on Win8 & 7 - haven't tried it on my Mac yet.. hopefully it will work without too many changes. |
|||||||||||
|
ace491
|
Has there been any advancement in this? Is Android Studio any more ready to support NDK and SDL2? Getting my SDL2 programs to run on android using Eclipse seemed excessively convoluted, but perhaps that's how all native is on android. Does Android Studio seem any simpler?
|
|||||||||||
|
SparkyNZ
|
I haven't heard anything and I keep nosing around the Android Developer and Gradle forum. Seems to be taking quite a while. AS looked better to me - Eclipse takes forever to load - but I have just left my Android development until last given the current situation. I'm working on a new cross-plaform app so I would like to use it, but its just not ready and there's little support if you get stuck. Microsoft's VS2015 is worth a look with its Android support though. |
|||||||||||||
|
SDL2 with android and the new anrdoid studio |
M2tM
|
Yeah I had a stackoverflow question about vs2015 setup, used to have a 500 point bounty but it expired:
http://stackoverflow.com/questions/36147257/how-do-i-set-up-visual-studio-2015-with-sdl2-for-android-ios-and-windows-devel Sent from my iPhone On Apr 7, 2016, at 9:46 PM, SparkyNZ wrote:
|
|||||||||||||
|
Hawkeye
|
Hi,
Found this thread in Google when searching for ways to get SDL working with the new Gradle build system for Android. I managed to get SDL and a simple example program compiling using gradle-experimental (which supports the NDK): https://github.com/stephen47/android-sdl2-gradle-template I've not tried it with Android Studio (just using the gradle wrapper command line) but I think it should work (my code is based off one of the Google NDK example projects). I'm just finding my way around Gradle so there might be better ways to do it (one of the things I want it to do it build the "main" library when assembleDebug is invoked). Hopefully you find it useful and would love to get some feedback if you find improvements Stephen |
|||||||||||
|