Importing LIBGDX library gdx-backend-android.jar into Android Studio Project - android-studio

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, don't mind the other errors, I first need to fix the GDX import.

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.

Related

Adding prebuilt native libraries to Android Studio project

I am currently working on a wearOS app written in Kotlin that needs to consume a native library.
I have cloned the library from github and built it. The output consists of a libs folder with 4 different subfolders containing .so files for the different ABIs and a java folder with two java classes to interact with the library.
I have been reading the android docs but I still can't figure out how I need to import these files in my project to actually use the library. I don't have a lot of experience in android development, could anybody explain to me wat to do or just point me to the right docs/integration guide?

How to use HttpClient in android studio app?

unfortunately this question was closed however it is spot on. Let me go through the steps as I am reproducing a legacy app issue that uses httpclient so switching is not an option YET (6 months out maybe).
create android studio app
try to use Httpclient and as he shows in the post above it is in red
I try to add this line in build.gradle to bring it in as a work around(even though core android also brings it in)
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
Then I get this error in android studio
`httpclient` defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for `httpclient` use `HttpUrlConnection` or `okhttp` instead), or repackaging the library using something like `jarjar`.
Ok, so I am using the wrong version so I run build scan and I see this so I bring this one in instead of the other version (android studio now sees HttpClient and can import it at this point)
I still get the same error though about conflicting android libs.
QUESTION: How do I fix the red in my legacy project and not have this error either?
My best bet seems to ignore the error. Will I have issues that I am not seeing though in the future?

Android-studio goes endless loop when trying to compile MLKIT-sample code

I'm trying to compile and run Google's MLKit sample https://github.com/googlesamples/mlkit. Code uses kotlin and there is one compiling issue, where I had to add '.toString()', when 'String' was expected, but got 'String?'. After that manual code correction gradle process tries to compile the project, but task ':app:mergeDexDebug' newer ends. Tried hours. I use Ubuntu 20.04, downloaded official Android-Srudio, unzipped to my home directory's subdirectory and let it to upgrade itself as it wanted.
Android-Studio wan't to upgrade MLKit project to use newer gradle and gradle-wrapper and tried both let upgrade to be done and not to upgrade, but there was no difference. Grdle-process continues until it goes to task ':app:mergeDexDebug', which newer ends.
I have downloaded latest java and set my set it in other projects's settings to be used and kit works fine with those project. Anothed option is use Android Studios internal java and it seems, that MLKit sample project uses that, because, when you open new project in Android-Studio, it start co compile MLKit sample projectit automatically and you don't have time to configure it by hand before to compile. Or yes, I have some time to comfigure foreground, because gradle works in background, until gradle is in the task ':app:mergeDexDebug', but it is hard to test result of that kind configuration, because you can't exit from Andpoid-Studio normally, but it warns you that gradle processes are still running and when you exit, java-processes will still keep running and if your kill them, but gradle cache will not be in normal state and there will be lockfiles etc and you can't use grade until you have removed gradle cache. So it is hard to study what goes wrong. Any idea?
Seems that problem was with gradle settings, too low memory setting. Because I could not compile original MLKit example projects, I started to build another project based on MLKit example projects code. With that process I had error in compilation also and adjusted gradle memory setting from original 256MB to 1024MB and continued. After some hours and some Android Studio restarts I checked original MLKit example project, and noticed that it had been compiled in background. I could install it in to my phone. By the way, this example project introduces bar code scanning and object detecting. Object detecting does not do anything reasonable, because it can maybe show objects in camera view or picture, but can not name them, but barcode scanning works fine.

VSCode and AndroidStudio Project setup to run flutter for device, web (and desktop?)

I have read a question/answer which states Flutter Web is a fork of Flutter and so one Android Studio (or VScode) project can't be built to handle both.
I'm not an expert on either (obviously) but I don't understand why the fact the libraries are forked implicitly precludes one from using the same source code for the different destinations.
Has anyone done so? And, if so, is there a skeletal project anyone would care to share?

Project is targeting frameworks not installed or are included as part of future updates to Visual Studio

I am attempting to convert the Microsoft.Health C# class library that is installed as part of the HealthVault SDK, using instructions provided here. After following these instructions, I get the following error when attempting to load the project into Visual Studio 2013.
"The project is targeting frameworks hat are either not installed or
are included as part of future updates to Visual Studio. See
http://go.microsoft.com/fwlink/?LinkId=287985"
Visiting the link takes me to .NET SDKs and Downloads. Once there, I have no clue on what needs to be done.
I do realize that one will have to leverage the Portable Class Library Contrib project to fill in some missing bits, especially code related to System.Security. This, I will deal with later.
Any one run into a similar problem?
Maybe so late but for those who have the same problem.
I had the same error in a project which was working perfect before updating VS2013 and finally after 3 hours looking for the source of the error I found that the error is about TargetFrameworkProfile.
In my case I sloved it like so:
Right click in the unloaded project in your solution and click Edit.
Find the TargetFrameworkProfile tag and set it as below:
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
At a guess, this is because you need to specify the TargetFrameworkVersion and TargetFrameworkProfile properties in the project file. Compare the .csproj you are trying to create to a newly created PCL project file, and make sure that everything that's not specific to your project matches.
I ran into the same issue and got it resolved by installing the latest Visual Studio Update

Resources