Run LibGDX project with Android Studio

I used the "installation interface" to create my LibGDX game projects. Then I imported them into Android Studio. At first, it did not show any errors, but when I tried to start the Android project, it gave me strange errors, for example:

java: cannot find character character: variable super location: class com.yan.waterworld.MainActivity

Here is the image: enter image description here

How can this be solved (or worked)?

+6
source share
6 answers

Update :

Starting with Android Studio 0.8.0, you can now run Java and Android modules. This will not work following these instructions (Android studio is based on Intellij). Gradle Configuration

Old :

They have forums and notice here: https://code.google.com/p/libgdx/wiki/AndroidStudio

Using libgdx with Android Studio

At Google I / O 2013, Android tools, the team released Android Studio and an IDE based on IntelliJ IDEA, focusing on the pure development of Android.

Android Studio, unfortunately, is not suitable for libgdx projects, since it allows you to create projects for Android. Standard Java projects are not supported, and it is unclear whether this will ever be available.

The cross-platform nature of Libgdx does not lend itself to Android Studio. This should not be a big obstacle, since libgdx projects benefit little from Android Studios features. For instance. layout previews are not relevant for libgdx since they do not use native Android user interface widgets. Native documentation support for the Android API is also not required for the libgdx application.

However, we will try to make the development of libgdx applications new Android Gradle system is possible in the near future.

If you must use Android Studio, check out this thread on the forums.

Alternatively, you can use Intellij IDEA with libgdx, potentially with Maven.

+16
source

Creating games in gdx works great in Android Studio. The best way to create a project for Android Studio is through gdx-setup. Please continue to the next article.

http://www.todroid.com/android-gdx-game-creation-part-i-setting-up-up-android-studio-for-creating-games/

It explains my experience using the gdx-setup application, running it on a PC platform, and the steps to import a gradle project and building the project in gradle.

When you finish the article, we hope that you will have a fully working sample game template in which you can start creating your own game.

+5
source

I tried to use a similar method used for my own libraries.

Last night I managed to run the examples; as a project from scratch in Android Studio and wrote a brief recommendation

I hope he helps you too, but I still really regret that you have no information or errors;)

Here is the link .. http://bgnstudio.wordpress.com

I tried to use this method in detail:

Create a new project in Android Studio.

From the nightly assembly libgdx, get;

Libgdx.so files within the armeabi/armeabi-v7a folders as needed. Gdx.jar and gdx-source.jar Gdx-backend-android.jar 

Create the lib and libs directories in the project folder.

Copy the armeabi *, gdx.jar and gdx-source.jar files in the "lib" directory.

Also copy gdx-backend-android.jar to the "libs" directory.

*

In the project tree; add gdx.jar and gdx-backend-android.jar as a library.

In the library settings add gdx-source.jar under gdx.jar; Then open the module settings and add these libraries depending. And check them out for compilation.

Archive the armeabi folders along with the parent directory into zip files and rename the extension from zip to jar.

 armeabi.jar : "/lib/armeabi/libgdx.so" armeabi-v7a.jar :"/lib/armeabi-v7a/libgdx.so" 

And move these jar files to the "libs" directory.

The final look of the folders will be like this:

 |-lib |---gdx.jar |---gdx-sorces.jar (added as source library of gdx.jar in library settings) |-libs |--- armeabi.jar |--- armeabi-v7a.jar |--- gdx-backend-android.jar 

Now modify the build.gradle file:

 dependencies { compile 'com.android.support:appcompat-v7:+' compile files('lib/gdx.jar') compile files('libs/gdx-backend-android.jar') compile fileTree(dir: 'libs' , include:'*.jar') } 
+4
source

Have you tried IntelliJ 13 ? Download here . This new version covers most of the features of Android Studio, but it can still create a Java Project. Take a look at this article.

This EAP build includes all of the new Android Studio features, with the exception of the new Project Wizard and AppEngine application endpoint integration. These latest features will also appear in our EAP builds in the coming weeks.

+1
source

Take a look at the libdgx documentation: https://code.google.com/p/libgdx/wiki/IntelliJIDEALibgdx

0
source

check the Advanced-> IDEA checkbox in the libgdx project setup tool, create the project and import it from android studio (you will need to add the resource folder to the desktop or maybe something similar), this works for me.

0
source

Source: https://habr.com/ru/post/945287/


All Articles