0
votes

After a hiatus of a couple of years I'm picking up Android development again.

I installed the newest Android Studio(4.1.1) with the latest Android SDK version (Android 11, API 30). After that I created a new project with gdx-setup.

If I add the old java source to my newly generated project I get this error:

error: package com.badlogic.gdx.backends.android does not exist

I'm not sure how to add this jar into the new project. In the Gradle configuration I see mentions of the backend, but it's not available.

I also downloaded the 'gdx-backend-android.jar' from the nightly build and put the jar in the Android library folder, all to no avail.

Does anyone actually know how to correctly add this dependency into my project?


I added the jar but still have an error, dont mind the other errors, I first need to fix the GDX import

I added the jar but still have an error, don't mind the other errors, I first need to fix the GDX import.

1

1 Answers

1
votes

The project dependencies are managed by Gradle, so there is no need for you to directly touch any .jar files at all.

The most likely issue you're facing is that you are trying to use Android-specific classes from the core module, which is platform agnostic.

In a typical libGDX project, you do almost all your game code in the core module so it can easily be compiled for any platform. The code you showed above would be in the android module, but your LiveWallpaperStarter class would be part of core.

Some might say there's no reason to use core at all if you're making a Live Wallpaper, since it can't run on any other platforms besides Android. But there is some advantage in keeping the rendering in core so you can test in a desktop game window, because you can more rapidly compile and run on the desktop. This library has some tools that make it easy to wrap your rendering code in a class that lets you simulate a live wallpaper on desktop, for testing.