SDL2.0.8 with Android Studio 3.0.1


#21

That should be all you need to do. Did you try deleting build and .externalNativeBuild dirs and rebuild?


#22

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:
image

The only Android.mk that would exist would be underneath the android-project\app\jni folder.

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…

image

Removing the build and .externalNativeBuld folders didn’t make any difference, sorry.


#23

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.


#24

Maybe when trying to delete the symlink you managed to delete the files :stuck_out_tongue:


#25

You are totally correct! :slight_smile: 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.


#26

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:

C:\androidprojects\SDL\app\src\main\assets

Actually no - it ws the correct place, just needed a subfolder :slight_smile:

C:\androidprojects\SDL\app\src\main\assets\52_hello_mobile

All working and running on my S4 now.


#27

Nice. It should not be quite this hard for a seconds time I hope :slight_smile:

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.


#28

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…


#29

It’s this issue again:


#30

Thanks again. Also noted for my tutorial - now I’m having SDL.h include errors but I can sort this out later tonight. Out of time now. :slight_smile:


#31

Third time lucky!

I’ll sort out the second attempt tomorrow. One big mistake I made this time around was missing out the /D on the mklink… That causes a bit of a problem :slight_smile:

And second time lucky! That “/D” caught me out twice.


#32

Man, I’m fed up with Android Studio :slight_smile: I tried changing compileSdkVersion to 21, added some Google dependencies, got some errors, reverted my changes and I’m stuck with this problem now:

image

My SDL symbolic link is definately there and correct. compileSdkVersion is back to 19. I’ve also tried “Invalidate Cache and Restart” but still no luck.

I stil have the last project I got working - and that is still building and working fine…

Argghh! Just found that the below line somehow went missing from SDLActivity.java:

package org.libsdl.app;


#33

you don’t need to compile with Android Studio. You can simple use ./gradlew assembleRelease


#34

Out of interest, how would I go about simply including pre-built SDL library? At the moment all of the example projects create a symbolic link to the SDL Android project actually re-build the SDL source.

It would be a lot nicer to build the SDL library once (once per each architecture I guess) and then simply include the compiled library.

I’ve done it this way:

  1. First I copied the libSDL2.so folders from the original built project as follows. Each architecture folder has its own libSDL2.so:

image

  1. I link the libSDL2.so into my test application as shown in my app\jni\src\Android.mk below:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libSDL2
LOCAL_SRC_FILES := C:/androidlib/SDL2-prebuilt/$(TARGET_ARCH_ABI)/libSDL2.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := main
SDL_PATH := C:/androidlib/SDL2-prebuilt

LOCAL_C_INCLUDES := $(SDL_PATH)/include

LOCAL_SRC_FILES := 52_hello_mobile.cpp
LOCAL_STATIC_LIBRARIES := libSDL2
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog

include $(BUILD_SHARED_LIBRARY)

No more building SDL everytime I create a new application. No more need for symbolic links etc. Once SDL has been built, I can just link and use it.


#35

you have an example there:


#36

How did you get this working in the end? I’m stuck at this stage.

Is there a way to not build armeabi by default? It’s still giving an error and not a warning and refuses to build anything.


#37

Hi. Yeah I’ve gotten a few projects building happily since then. Which part are you stuck on, or what sort of errors are you having?

You can just build the one architecture that you want. In your App’s build.gradle file you just need to specify which architectures you want to build. I build one during development on my phone and then comment it out so I can build all architectures and deploy an .apk on my car stereo for example.

Here’s what my app’s build.gradle looks like - note externalBuild and ndk sections.

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.sparkynz.myapp"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "2.0"
        multiDexEnabled false
        externalNativeBuild {
            ndkBuild {
                targets "FCPlayPaul",
                        "LHASrc",
                        "SQLite",
                        "main"
            }
        }

        ndk {
            abiFilters 'armeabi-v7a' // Just build the one architecture
        }

    }

#41

Okay it’s working now. I was making several mistakes in the process including upgrading to gradle 3.1.1 when prompted, mixing up SDL2_mixer with SDL_mixer and automatically doing things the old way when we were using ANT.

I’ve been through hell and back setting Android build up, so I should be able to help others if they’re stuck.


#42

hello
you are the solution for SDL2.0.8 whit Android Studio 3.0.1 .i read for all conversation. I confuse


#44

Hello,

I have tried several times the Android part of the tutorial with AndroidStudio 2.3 + 3.0 and SDL 2.0.5 + 2.0.8 but it doesn’t work anymore.
It seems that the Turorial is out of date :frowning:
Any idea when an updated version of the Lazyfoo Tutorial will it be release?
Thanks.
:sunglasses: