I created new libgdx project and i want to run desktop application in Android Studio. Is there something to do with run configurations? In Eclipse i can just choose Run as Java Application.
Easy way to run a java program in Android Studio would be, 1) Create a java Class say "Test.java" in Android Studio. 2) Write your code eg, a Hello World program to test. 3) Right click on the Java class and select the option "Run 'Test.main()'" or press Cntrl+Shift+F10.
How to Run My App on Android 1 In the toolbar, select your app from the run configurations drop-down menu. 2 From the target device drop-down menu, select the device that you want to run your app on. If you don't have any devices configured, then you need ... 3 Click Run . See More....
In case you are not used to doing this outside of an IDE, here’s the command: Make sure the program compiled properly: Android cannot run Java class files directly. They have to be converted to Dalvik’s DEX format first (yes, even if you are using ART): NOTE: Android Build Tools v28.0.2 and later contain a dx upgrade, called d8.
Sticking with Java would have the benefit of avoiding all of the native ABI hassle and also being able to call into the Android runtime. So how do we do that? Let’s start with the Java program we want to run.
Ok, i did it. Here is the solution https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA#running-your-project
Run -> Edit Configurations...
, click the plus (+
) button and select Application.
Set the Name to Desktop
.
Set the field Use classpath of module
to desktop
, then click on the button of the Main class
field and select the DesktopLauncher
class.
Set the Working directory
to your android/assets/
(or your_project_path/core/assets/
) folder!
Click Apply
and then OK
.
You have now created a run configuration for your desktop project. You can now select the configuration and run it.
Right click on the main method (or anywhere in the main class) and select Run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With