There appears to be a bug on IntelliJ Idea which prevents the app from launching on Desktop from both IntelliJ and Android Studio on a Mac (still to confirm if it affects Windows as well). A Reddit post was created on /r/libgdx as well as an issue created on Jetbrains issue tracker (see https://www.reddit.com/r/libgdx/comments/612c7d/can_run_on_android_cannot_run_on_desktop/ for details).
Even if it's no a libGDX bug I believe it is helpful to keep track on the progess of this as many users will see this crash when trying to launch on desktop using their IDE, feel free to close it otherwise.
Try to launch on Desktop a libGDX project using Intelli J version 2017.2.1 or Android Studio 2.3.3 on a Mac.
1.9.6
java.lang.ClassNotFoundException: cannot find class com.badlogic.gdx.ApplicationListener
How are you importing the project?
Ok, I've been trying different stuff and it may be an issue with my specific IDE and not related to the Reddit post. If I import a new project on Android Studio (File -> New -> Import Project) it runs on Desktop through the IDE Ok for a while and then starts failing (with the described error) and never recovers. On several attempts the trigger to start failing has been different so either I try to find out what caused it or I may create a fresh new environment in case it's gone corrupt. I'll close this issue for the moment.
Found the issue (it's not related to the Reddit post described in Issue Details). Setting Gradle wrapper to version 3.3 fixes it (it took me a bit to find out because Gradle version changes were not being applied immediately). On Gradle 3.5.1 or 4.0.2 the game doesn't launch on Desktop from the IDE neither on Android Studio nor Idea both on Windows and Mac even if it does from gradlew using console.
I'm facing the same issue right now... Is downgrading really a fix? More like a temporary workaround. Moreover, on the latest Android Studio, you're forced to use the updated version of Gradle plugin and this problem cannot be fixed with this workaround.
I believe the problem should be fixed on a deeper level.
This is something discussed here: https://github.com/libgdx/libgdx/issues/4946
Android Studio 3.0 uses Gradle 4.+
Unfortunately LibGDX is not compatible (for now). it will be some day according to https://github.com/libgdx/libgdx/issues/4698
You can use another IDE or an older version of Android Studio using on of the links provided in the issue above.
and yes, it is a work around for now.
I got it to work with a minor hack and some user intervention required. Change task run(...)
to task runAndroid(...)
in the android build.gradle. I believe the issue is that the desktopbuild.gradle
also has a task called run. Android studio appears to be blending and/or calling both causing the error.
Also To make sure the "build process" closes properly you will need to add System.exit(0);
to the end of DesktopLauncher.main().
Ok that was much more painful than it needed to be. Turns out you can just tell Android Studio to run a JAR application
and execute gradle :desktop:dist
before hand.
For this approach set Path to JAR
to PROJECT_ROOT\desktop\build\libs\desktop-1.0.jar
and Working Directory
that same as you would for running an application. Lastly in the Before launch
at the bottom I added a gradle task with project YOUR_GAME:desktop
and task desktop:dist
.
Just for clarity, you need to add a new run configuration, you can't modify your existing one since it isn't the proper type.
Run/Debug Configurations
page.JAR Application
.Path to JAR
and Working directory
as above.Before launch
gradle task as above.See #4698 my last comment it is now fixed using normal Application configuration.
Morning all
I have a LibGDX project for iOS (MOE), Android and Desktop. I have just discovered that Desktop is not longer running. IT IS in KOTLIN!
I did try to upgrade to gradle 4.4, build 3.1.1 and latest AS but then non of the projects would compile with weird error like Program type already present: com.badlogic.gdx.sql.Database. I even took out all refs to this
So now I am running
Gradle 4.1
Build tools 2.3.3
All I want to fix is getting the desktop app working (iOS/ Android work If I run the normal Desktop Launcher I get
Error: Could not find or load main class com.burfdevelopment.hack24.desktop.DesktopLauncher
If I do the .jar workaround, I get
no main manifest attribute, in /Users/snrb/Documents/Hack24-Cross/Hack24/desktop/build/libs/desktop-1.0.jar
You must be using at least gradle 4.6 to run on newest IDEA and AS.
So 4.6 Gradle, 3.12 AS and what version of Build tools?
Desktop, Android and iOS work fine on this?
see snapshot versions declared here: https://libgdx.badlogicgames.com/versions.html
Updating I get Program type already present: com.badlogic.gdx.sql.Database
Message{kind=ERROR, text=Program type already present: com.badlogic.gdx.sql.Database, sources=[Unknown source file], tool name=Optional.of(D8)}
Invalidate caches, and run a gradle sync then a full rebuild
So I had to remove the sql libs for this to compile for Android.
Desktop/iOS still does not run, it errors with (All I did is right click run DesktopLauncher/MOE)
(Kotlin 1.2.40, RoboVm 2.3.3, MOE 1.4.1, Build tools 3.1.0, AS Latest, Gradle 4.6)
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at com.android.build.gradle.BasePlugin.lambda$configureProject$1(BasePlugin.java:436)
at sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy124.graphPopulated(Unknown Source)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:128)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:46)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:210)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:140)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:115)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:49)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:32)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
When I do ./gradlew desktop:dist
I get:
Starting a Gradle Daemon, 1 incompatible and 3 stopped Daemons could not be reused, use --status for details
Configuration on demand is an incubating feature.
Configure project :
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
Using already downloaded SDK: C:\Users\Simon.Burfield.moe\moe-sdk-1.4.1
Configure project :core
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
FAILURE: Build failed with an exception.
I'll repost the solution of @adam4813 that is mentioned in #4698 because it also took me a while to stumble upon it.
I changed the Before Launch to Build Project instead of Build when using an Application configuration. To do this, in the Before launch box at the bottom of the Run/Debug Configuration dialog, for an Application configuration, click the green + and add Build Project and then select the Build line and click the red - to remove it.
I'm struggling with the same error, but for iOS target (RoboVM).
Exception in thread "main" java.lang.NoClassDefFoundError: ru/serdjuk/m3l/game/M3lMain
at ru.serdjuk.m3l.game.desktop.DesktopLauncher.main(DesktopLauncher.java:13)
Caused by: java.lang.ClassNotFoundException: ru.serdjuk.m3l.game.M3lMain
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
result of SHIFT+10 (Desktop)
gradlew desktop:run - is working, but it's uncomfortable
I moved the contents of the old project's root folder to a new project without updating the gradle, but the error remained
how to fix this error ?
in project I use the kotlin and coroutines kotlin in the project
...in path: core/build/classes not created main class
AS 3.1.3
com.android.tools.build:gradle:3.1.0
gradle-4.6-bin.zip
Please provide the full instructions to reproduce your issue, from setting up a new project, what configurations you are choosing and how you are importing. If you can reproduce with a new project please open a new issue and we will resolve it.
I have just tried a new project, following the official instructions and cannot reproduce your error given your steps.
The problem was in Convert Java file to Kotlin file
When the main class in the project :core: is the Kotlin file, this error occurs.
DesctopLauncher.class does not see a GdxGame.kt
I had the same Problem.
I just created a new gradle configuration named Desktop, set the Gradle project to the project's path and in Tasks I entered:
desktop:run
@burf2000 > I was getting your last error with gradle 4.5.1 and google's gradle android plugin 3.1.0.
Updating to gradle 4.6 and gradle android 3.2.0 fixed the issue, as suggested in https://issuetracker.google.com/issues/77605097.
Still having thes issue, any fix?
Most helpful comment
Ok that was much more painful than it needed to be. Turns out you can just tell Android Studio to run a
JAR application
and execute gradle:desktop:dist
before hand.For this approach set
Path to JAR
toPROJECT_ROOT\desktop\build\libs\desktop-1.0.jar
andWorking Directory
that same as you would for running an application. Lastly in theBefore launch
at the bottom I added a gradle task with projectYOUR_GAME:desktop
and taskdesktop:dist
.