I’m trying to build the included android-project within SDL-2.0.8-11687. I get the following error:
W:\SDL-2.0.8-11687\android-project\app\src\main\java\org\libsdl\app\SDLActivity.java:220: error: cannot find symbol
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
^
symbol: variable SYSTEM_UI_FLAG_IMMERSIVE_STICKY
location: class View
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
I have tried changing the Android API versions in my AndroidManifest.xml to:
Sorry people - I would have uploaded a GIT rep and tried out other suggestions but Android Studio is being a pain. I have tried running this project on 3 different (Windows) machines and I get different results everywhere. At home I’m getting lots of NDK errors now such as:
I’ll need to completely remove and re-install Android Studio once again before I can try anything more with this. I’m glad I don’t pay per Gb anymore for my Internet usage!
The latest android studio deprecated armeabi and mips builds, but they are still compiled by default. It says error but really it’s just a warning and you can ignore it if you want. I.e. it should not cause the build to fail in my experience.
Thanks. Unfortunately it is definitely stopping on the following error though:
W:\Android\sdk\ndk-bundle\build\core\build-binary.mk
Error:(693) Android NDK: Module main depends on undefined modules: SDL2
Error:(706) *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies) . Stop.
I’m just googling now to figure out how to set APP_ALLOW_MISSING_DEPS…
And the fact that I don’t have a cpp or jni folder in the Android Studio project doesn’t help so I can’t easily go into my Android.mk/Application.mk from there. The whole project is a mess on the current machine I’m using - and that was after reinstalling Android Studio and NDK.
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…
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: C:\Program Files\Java\jdk1.8.0_91
Same problem.
Tried “File->Invalid Caches/Restart”
Same problem.
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.
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 app/build.gradle file.
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 SDL/android-project/app/jni
Add your c source code to SDL/android-project/app/jni/src and modify the Android.mk there accordingly
Done. Now you can build from the command line by running gradlew.bat assemble or 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’).
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.
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 app/jni dir.
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 build and .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