Are you still trying to build the SDL android example project? There should be a
app/jni dir where you need to copy (or symlink) sdl into.
Are you still trying to build the SDL android example project? There should be a
Yes I was just trying to build it as-is. Surely we still don’t need to go through that complication of creating symbolic links to SDL etc again? I went through that on the Mac when building using ant etc from the command line and that was really painful.
With Android Studio there should be a project already provided so people can just build it and ‘go’ without following long instructions. That’s what I would like to see in an ideal world.
Yes. I agree completely. I’ve actually made something like that, but I ran into some issues with gradle and android studio so it’s not 100% finished. And I haven’t even tried getting it into SDL yet
I’m just wondering whether to give LazyFoo’s tutorial a go now… I guess I’m more frustrated with the fact that I’m struggling to continue with my own project that uses ant etc. The big barrier I hit with that project was that I couldn’t figure out how to include various GoogleSign-in packages… and I struggle on the Mac… I thought installing Android Studio on Windows would be my silver bullet. Oh well I may as well give it a go. Given that the tutorial was for AS 2.3.3 I just hope it works with AS3.0.1…
OK, I’m now trying to follow Lazy Foo’s tutorial…
- I had to change Change
- I downloaded Android SDK 16
Try to Make the project and I get this:
C:\androidprojects\SDL\app\src\main\java\org\libsdl\app\SDLActivity.java:7: error: cannot find symbol import java.util.Objects;
Gradle Console also shows:
file or directory 'C:\androidprojects\SDL\app\src\debug\java', not found
Debug console output has this line:
15:19:12.229 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -source 1.6 -target 1.6 -d C:\androidprojects\SDL\app\build\intermediates\classes\debug -encoding UTF-8 -bootclasspath C:\androidsdk\platforms\android-16\android.jar -g -sourcepath -proc:none -XDuseUnsharedTable=true -classpath -s C:\androidprojects\SDL\app\build\generated\source\apt\debug C:\androidprojects\SDL\app\src\main\java\org\libsdl\app\SDL.java C:\androidprojects\SDL\app\src\main\java\org\libsdl\app\SDLActivity.java C:\androidprojects\SDL\app\src\main\java\org\libsdl\app\SDLAudioManager.java C:\androidprojects\SDL\app\src\main\java\org\libsdl\app\SDLControllerManager.java C:\androidprojects\SDL\app\build\generated\source\r\debug\org\libsdl\app\R.java C:\androidprojects\SDL\app\build\generated\source\buildConfig\debug\org\libsdl\app\BuildConfig.java
Just read a StackOverflow post that claims my Java version must be wrong. The java.utils.Objects were only introduced with Java 7 so it says, but I should have Java 8. If I run from a command prompt:
C:\Users\Paul>java -version java version "1.8.0_91"
However, Android Studio was using the embedded Java version. So… I tried changing it as follows:
Change Java version File->Project Structure - stop using internal JDK:
Help please? I’m keeping notes as I go so I could write my own AS3.0.1/SDL2.0.7 tutorial if need be.
That’s probably an issue with the 2.0.7 SDL. See SDL 2.0.7 Error Andriod Studio
So try a newer snapshot or the latest sources. There have been quite a lot of Android build braking changes lately so your mileage may vary.
Also if you update the gradle wrapper you probably need to change other things in the
build.gradle also. See https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
In practice you need to add the google repositories and update the plugin version to the build.gradle in the root folder and change “compile” -> “implementation” in the dependencies in the
Thanks. That link you said was consistent with what I had. Unfortunately the 2.0.8-11724 snapshot has rendered LazyFoo’s tutorial completely out of date. Importing the project from the 2.0.8 snapshot doesn’t even ask me where I’d like the destination project to be so I had to start guessing what to do from that point.
The jni folder seems to be expected as
app\jni folder now instead of
app\src\main\jni. The “Link C++ Project with Gradle” option doesn’t appear in Android Studio’s context menu anymore and all I can see in the Project window is an empty “cpp” folder.
I added the SDL2 symbolic link under the
app\jni folder and I get these errors:
C:\androidsdk\ndk-bundle\build\core\build-binary.mk Error:(692, 0) Android NDK: Module main depends on undefined modules: SDL2 Error:(705, 0) *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies) . Stop.
I am completely stuck now.
I’m sorry that I didn’t understand the last two sentences in your reply - if I’ve started a new project for 2.0.8-11724 then I’m guessing I would be using whatever version of Gradle/wrapper was defined in the snapshot.
Sounds like the linking is not done correctly. If you are on windows you can use something like:
mklink /D SDL c:\libs\SDL
Run that in the
app\jni dir but change the last path to be an absolute path to you SDL. Also you need to do that from an admin command prompt.
After that it should look something like this:
If you linked to the correct place, entering the SDL dir you will see the root of the sdl sources
I haven’t looked at LazyFoo, but this is the simplest way to get the current version to work:
- Use a somewhat new snapshot or sources from version control
- Link your SDL directory to
- Add your c source code to
SDL/android-project/app/jni/srcand modify the
- Done. Now you can build from the command line by running
gradlew.bat assembleor open android studio and run from there. If Android studio asks you to upgrade the project to newest plugin/gradle don’t do it (yet at least).
I just tried this with the latest sources and didn’t do anything else and it worked.
Later you can modify the app name/package etc. or update to newer gradle, but try to get this to build and run first.
Thanks for that. I think the last problem may have been the name of the symbolic link. LazyFoo’s tutorial assumes there is a link to SDL2. Your suggestion showed SDL (without the ‘2’).
I removed the SDL2 link, added SDL2 as below:
Directory of C:\androidprojects\SDL\app\jni 24/10/2017 10:01 a.m. 37 Android.mk 07/12/2017 12:22 p.m. 212 Application.mk 07/12/2017 12:31 p.m. <SYMLINKD> SDL [C:\androidlib\SDL-2.0.8-11724] 07/12/2017 12:20 p.m. <SYMLINKD> SDL2 [C:\androidlib\SDL-2.0.8-11724] 07/12/2017 12:21 p.m. <DIR> src C:\androidprojects\SDL\app\jni>del SDL2
This appears to have moved forward somewhat. It started trying to build the “52_hello_mobile.cpp” source file. Unfortunately that failed due to not being able to link with the SDL library.
[armeabi] SharedLibrary : libmain.so C:/androidprojects/SDL/app/jni/src/52_hello_mobile.cpp:248: error: undefined reference to 'SDL_DestroyTexture'
I still don’t know why the cpp folder is showing empty though. Its not very helpful that I can’t see the Android.mk and .cpp files. No doubt this relates to some gradle version or plugin. I thought the days of the ‘experimental plugin’ were gone.
I also clicked on “Remind me Tomorrow” for the below dialog:
What my problem be now? Should I have created a seperate project to build the SDL2 library itself?
My test app’s Android.mk contains:
LOCAL_SHARED_LIBRARIES := SDL2
…but I have no idea where that would be located.
Your listing still shows the SDL2 symlink. Make sure have deleted that because the project is setup so that it’s trying to build every subfolder in the
Android Studio seems to not be able to sync the project because the build is failing. It will probably show the file once the build doesn’t fail anymore.
Maybe try deleting
.externalNativeBuild from both the android-project and app dirs to clean any old stuff and try to rebuild.
btw. the SDL2 library is defined in the SDL dir you just symlinked. Like I said the project is setup so that it searches for
Android.mk in each subdir. You can look at
app/jni/SDL/Android.mk. It defines all the stuff SDL is building
Yes I removed the SDL2 symbolic link:
Directory of C:\androidprojects\SDL\app\jni
07/12/2017 12:51 p.m. <DIR> . 07/12/2017 12:51 p.m. <DIR> .. 24/10/2017 10:01 a.m. 37 Android.mk 07/12/2017 12:22 p.m. 212 Application.mk 07/12/2017 12:31 p.m. <SYMLINKD> SDL [C:\androidlib\SDL-2.0.8-11724] 07/12/2017 12:21 p.m. <DIR> src
That should be all you need to do. Did you try deleting
.externalNativeBuild dirs and rebuild?
If I look at app/jni/SDL (which is the symbolic link folder), I don’t have an Android.mk at all.
My SDL symbolic link points to the SDL-2.0.8-11724 snapshot:
The only Android.mk that would exist would be underneath the
Just to be clear, one of LazyFoo’s tutorial steps is to choose “Import Project…” This used to ask for a destination folder. With AS 3.0.1, it doesn’t ask for a destination folder. What I did instead was make a copy of the ‘android-project’ folder from the SDL snapshot and I put that under the
C:\androidprojects\SDL folder. I could have called it SDLTest instead but I didn’t…
Removing the build and .externalNativeBuld folders didn’t make any difference, sorry.
There should be a bunch of files in the root of that dir. including the
Android.mk. I looked in the snapshot zip that was linked earlier and it certainly has them.
Maybe when trying to delete the symlink you managed to delete the files
You are totally correct! I remember thinking using ‘del’ was bad to delete the symlink. I thought mklink itself would have had an option to do it but no…
Wow! Something built and deployed this time. Black screen and immediate shutdown but I’m sure I can debug that.
OK. So I have yet to redo all of this on my home PC and ‘mobile’ laptop. I’ll repeat the process and make a tutorial out of it… which I may as well put onto this forum once I’m done.
Thanks for all of your help!
Next I’ll be back to the challenge of seeing if I can get multiple source and libraries to be included in AS… That will deserve another thread though if it happens again.
FYI, the reason my app is crashing is because of a missing hello.bmp file. I put this in the below folder but I bet that’s the wrong place:
Actually no - it ws the correct place, just needed a subfolder
All working and running on my S4 now.
Nice. It should not be quite this hard for a seconds time I hope
So basically just these steps should give you something that builds:
I still think that’s 3 steps too much and the sample project should be changed to build without any fiddling around like that.
Also I think you can delete symlinks from windows explorer and it should not delete the target dir.
Yeah it should have worked OK second time around but no… something different again. More Android Studio grief.
I’m trying this on my ‘mobile’ laptop now. This time around I get this:
C:\androidprojects\SDLTest\app\src\main\java\org\libsdl\app\SDLActivity.java Error:(220, 17) error: cannot find symbol variable SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Maybe I haven’t downloaded the API 14 or 16 SDK. I’ll see if that works…