[VTM] libgdx desktop ClassNotFoundException

205 views
Skip to first unread message

Gustl22

unread,
Jan 10, 2018, 8:21:58 AM1/10/18
to mapsforge-dev
Hi,

Maybe I'm birdbrained, but I'm trying to run the VTM playground/desktop applications, but I always got this message:

Fehler: Hauptklasse org.oscim.test.MapsforgeTest konnte nicht gefunden oder geladen werden.
Process finished with exit code 1


Translation: Main class org.oscim.test.MapsforgeTest/GdxMapApp could not be found or load.
So it doesn't even compile. But while building no error is thrown.

What I tried to do:
- Run on Windows 10 in AS
- Run on Ubuntu 17.10 in AS
- Reinstalled AS
- Fresh reload project from master
- Add mapfile to program arguments of course
- Edit config classpaths (to classpaths of module)
- Edit config working directory (to assets etc...)
- Run dependencies/classes/build/... in gradle window
Tried it in all variations...

The confusing point is:
All classes (with main() method) work, which do not extend from a class which implements the gdx ApplicationListener.

So am I missing any dependency?

Then I found this page on Stackoverflow.
But there's no "other -> Run" at vtm-playground gradle options. And the "application -> run" throws another error:

Error:(74, 1) Execution failed for task ':vtm-android-example:run'.
> java.io.IOException: Cannot run program "null/platform-tools/adb": error=2, File or folder not found

Although the android-example has nothing to do with the playground I think.

Thanks for your help, I'm just before to freak out.

Gustl

Emux

unread,
Jan 10, 2018, 8:31:20 AM1/10/18
to mapsfo...@googlegroups.com
That was working always and got broken somewhere with new Gradle.

See my comment in relevant issue here.
I just enabled in build.gradle of VTM desktop apps the Gradle application plugin.

For vtm-playground can change there the mainClassName to run each example and pass args, e.g.:

./gradlew :vtm-playground:run -Pargs=/path/to/map

And can save such configuration in AS.

BTW the "run" task is under "application", offered by application plugin.

--
Emux

Emux

unread,
Jan 10, 2018, 8:43:48 AM1/10/18
to mapsfo...@googlegroups.com
BTW if call simple ":run" AS can run all (desktop + Android) apps in project together.

That's why it's recommended to use the module too, like ":vtm-playground:run".

--
Emux

Gustl22

unread,
Jan 10, 2018, 9:38:26 AM1/10/18
to mapsforge-dev
Wow, thank you Sir! Worked excellent!

Maybe can add a desktop.md in docs to inform newcomers?


BTW if call simple ":run" AS can run all (desktop + Android) apps in project together.


Yes, thats what I called before, then the second error appeared (Cannot run null/plattform/adb). But seems uninteresting now ;D

Thanks again :)
Auto Generated Inline Image 1

Emux

unread,
Jan 10, 2018, 9:40:28 AM1/10/18
to mapsfo...@googlegroups.com
> Maybe can add a desktop.md in docs to inform newcomers?

Indeed we seem needing that now. :)

--
Emux

Emux

unread,
Jan 12, 2018, 7:59:16 AM1/12/18
to mapsfo...@googlegroups.com
I created a desktop documentation for that.

If there are more to be mentioned please inform or even better can post a PR!

--
Emux

Longri, Andre Höpfner

unread,
Jan 12, 2018, 8:05:48 AM1/12/18
to mapsfo...@googlegroups.com
Ok now I can start the vtm-playground but only if a Android device conected! And I can not start desktop only! 
If I start vtm-theme-comperator it starts Android and Playground on desktop but now theme-comperator!


--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.
To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/51176a92-1e07-7809-54a7-d8ed30636d26%40gmail.com.

For more options, visit https://groups.google.com/d/optout.

Longri, Andre Höpfner

unread,
Jan 12, 2018, 8:13:11 AM1/12/18
to mapsfo...@googlegroups.com
Even debugging doesn't work for me, it doesn't stop at a breakpoint!


I know it's been a lot of work, but I ask you to think about returning to Gradle 3. x until everything runs smoothly, at Gradle!

Emux

unread,
Jan 12, 2018, 8:14:48 AM1/12/18
to mapsfo...@googlegroups.com
See my related comment above.

If use simple :run task on a module (like with double-click) then AS starts all runnable modules!

The proper way is to use module prefix with the run:

./gradlew :vtm-playground:run -Pargs=/path/to/map

in command line, or edit the run configuration like in screenshot.

--
Emux
android_studio.png

Longri, Andre Höpfner

unread,
Jan 12, 2018, 8:35:09 AM1/12/18
to mapsfo...@googlegroups.com
Ok, works for playground, but without debugging!
And not working with theme-comparator

Inline-Bild 1


And I have not tested iOS!

--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.
To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Emux

unread,
Jan 12, 2018, 8:44:47 AM1/12/18
to mapsfo...@googlegroups.com
> Ok, works for playground, but without debugging!

Haven't checked that lately, and don't know if Gradle 4 or Android Studio 3.0.1 (stable channel) are responsible.


> And not working with theme-comparator

Cannot confirm that, either with command line or UI (screenshot) it runs.

./gradlew :vtm-theme-comparator:run

--
Emux
comparator.png

Emux

unread,
Oct 1, 2018, 12:48:33 PM10/1/18
to mapsfo...@googlegroups.com
With latest Android Studio 3.2 the Desktop samples seem to run again directly from inside the IDE.

Just do a clean build before or via command line:

./gradlew clean build

--
Emux

Gustl22

unread,
Nov 25, 2018, 8:02:55 PM11/25/18
to mapsforge-dev
How to create a executable jar from gradle?

I added this to playground build.gradle:
jar {
manifest {
attributes(
// 'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'org.oscim.test.gdx.poi3d.Gdx3DTest'
)
}
}

But when I run it via java command it doesn't find the main class:

path/to/repo/mapsforge/vtm/vtm-playground/build/libs$ java -jar vtm-playground-master-SNAPSHOT.jar
Error: Could not find or load main class org.oscim.test.gdx.poi3d.Gdx3DTest


Class Path should be the current directory, so where's the fault... (need executable jar for debugging via gapid)

Emux

unread,
Nov 26, 2018, 2:35:56 AM11/26/18
to mapsfo...@googlegroups.com
Probably need a "fat jar" task like in vtm-theme-comparator to collect all dependencies.

--
Emux

Gustl22

unread,
Nov 29, 2018, 3:37:41 AM11/29/18
to mapsforge-dev
Thanks for your hint. But can't even run theme-comparator over "java -jar" command as it doesn't has Main-Class path specified in the Manifest file although I didn't change gradle file.
Did you manage to run desktop without IDE?

Emux

unread,
Nov 29, 2018, 3:53:32 AM11/29/18
to mapsfo...@googlegroups.com
If run "fatjar" Gradle task of vtm-theme-comparator, it will produce a "vtm-theme-comparator-master-SNAPSHOT-jar-with-dependencies.jar" (~13MB).

Its manifest contains the main class and can run it outside the IDE.

--
Emux

Gustl22

unread,
Nov 29, 2018, 4:01:06 PM11/29/18
to mapsforge-dev
As always, gave me the correct answer!
Was confused that "jar"-only task works with default build and the "fatjar" does not (only works as own task). And java's errors not really helped me solving the issue.
Thanks very much ;D Spent hours on this.
Reply all
Reply to author
Forward
0 new messages