I have snap witch use the plugin gradle, snapping using the ‘sudo snapcraft cleanbuild’ command.
After snapping and installing it run fine until getting to line of code witch use firebase (google library).
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/auth/Credentials
at DataBase.DatabaseController.<init>(DatabaseController.java:11)
at Main.main(Main.java:8)
Caused by: java.lang.ClassNotFoundException: com.google.auth.Credentials
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
The crash is only after I snap, Not when running from the IDE and not when running the jar file.
This is my build.gradle:
plugins {
id 'java'
id 'application'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = 'Main'
project.buildDir = 'SNAPCRAFT_GRADLE_OUTPUT_DIR'
repositories {
mavenCentral()
}
jar {
baseName = 'project-name'
version = '1.0.0'
manifest {
attributes(
'Main-Class': 'Main'
)
}
}
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'com.google.firebase:firebase-admin:6.8.1'
}
And this is my snapcraft.yaml:
name: project-name
version: '0.1'
summary: A java example
description: this is not much more than an example
#base: core18
grade: stable # must be 'stable' to release into candidate/stable channels (devel)
confinement: classic # use 'strict' once you have the right plugs and slots (devmode)
architectures: [all]
apps:
project-name:
command: java -jar $SNAP/jar/project-name-1.0.0.jar
parts:
local:
plugin: gradle
source: .
gradle-output-dir: 'SNAPCRAFT_GRADLE_OUTPUT_DIR/libs'
I use IntelliJ as my IDE.
It may be one of too reasons, All my external libraries aren’t include in my snap or the libraries after snaping get different name (possible duplicate ).
Trying to use another library getting the same error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jsoup/Jsoup
at Main.main(Main.java:21)
Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more