question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception in thread "main" java.lang.NoClassDefFoundError:

See original GitHub issue

Issue details I catch the exception when:

  1. I am importing my old project into a new one (the contents of the core folder root)
  2. in a new project, I change the main class Java file to Kotlin file

AS 3.1.3 build.gradle (Project) = classpath ‘com.android.tools.build:gradle:3.1.0’ build.gradle (Project) = classpath ‘com.android.tools.build:gradle:3.1.3’ gradle-wrapper.properties = distributionUrl=https://services.gradle.org/distributions/gradle-4.6-bin.zip gradle-wrapper.properties = distributionUrl=https://services.gradle.org/distributions/gradle-4.4-bin.zip gradle-wrapper.properties = distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip all “compile” replaced to “implementation”

If my English is too bad, then please see the video

Reproduction steps/code Create a new project. Convert the core: main Java class to Kotlin class and run Desktop. Code/Convert Java file to Kotlin file or Download tester.zip

  1. run desktop project = work
  2. uncomment the line of code img = new AAA (). GetTexture (); and run again = does not work (in the commented line of code, the AAA class is the Kotlin class)

Version of LibGDX and/or relevant dependencies 1.9.8 + Kotlin

Stacktrace

Exception in thread "main" java.lang.NoClassDefFoundError: com/mygdx/game/MyGdxGame
	at com.mygdx.game.desktop.DesktopLauncher.main(DesktopLauncher.java:10)
Caused by: java.lang.ClassNotFoundException: com.mygdx.game.MyGdxGame
	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

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
ghostcommented, Aug 1, 2018

I think this is a known issue and not really caused by libgdx. Try running the desktop project from gradle task: in Android Studio open the Gradle projects panel on the right side -> :desktop -> Tasks -> application -> run

This solved the issue for me

0reactions
itsabhiaryancommented, Aug 6, 2018

It’s works, I don’t How/Why ?

Today again I tried to run desktop module using Run/Debug Configuration and it works.

My project configuration :

  1. Generate new project using latest build
  2. Android Studio 3.1.3
  3. Kotlin in core module
  4. org.gradle.configureondemand=false in gradle.properties
  5. Configure on demand disabled in my IDE(Android Studio)
  6. Android gradle plugin version 3.1.3
  7. Gradle version 4.6
Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception in thread "main" java.lang.NoClassDefFoundError
lang.NoClassDefFoundError is a common error in Java that occurs if a ClassLoader cannot find a particular class in the classpath while trying to...
Read more >
exception in thread 'main' java.lang.NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError ... This . tells java that your classpath is your local directory.
Read more >
Exception in thread "main" java.lang ... - CodeGravity
Basically, the Exception in thread "main" java.lang.NoClassDefFoundError: means, that the class which you are trying to run was not found in the classpath....
Read more >
How to Resolve the NoClassDefFoundError in Java - Rollbar
The NoClassDefFoundError is a runtime error in Java that occurs if the Java Virtual Machine (JVM) or a ClassLoader instance attempts to load ......
Read more >
java.lang.NoClassDefFoundError - DigitalOcean
java.lang.NoClassDefFoundError is runtime error thrown when a required class is not found in the classpath and hence JVM is unable to load it ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found