【发布时间】:2019-10-01 04:44:40
【问题描述】:
我正在使用 Gradle 在 Eclipse 中构建一个应用程序。 当我通过从 Eclipse 运行来测试应用程序时,一切正常 - 但是,当我尝试导出并运行 .jar 文件时,我收到以下错误:
Failed for: .\ServiceAccountKey.json (The system cannot find the file specified)
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/firebase/cloud/FirestoreClient
at main.Main.getSuroviny(Main.java:105)
at main.Main.main(Main.java:39)
Caused by: java.lang.ClassNotFoundException: com.google.firebase.cloud.FirestoreClient
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
我的 build.gradle 文件如下所示:
apply plugin: 'java-library'
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
google()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:23.0'
implementation 'com.google.firebase:firebase-admin:5.8.0'
implementation 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-core:16.0.6'
//dependency for using firebase database
implementation 'com.google.firebase:firebase-database:16.0.6'
//dependency for email and password authentication
implementation 'com.google.firebase:firebase-auth:16.1.0'
//dependency for cloud storage
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-firestore:18.0.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
// Include dependent libraries in archive.
jar {
manifest {
attributes "Main-Class": "main.Main"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
我已经仔细检查了所有导入和实现,根据我在 Firestore 文档中找到的信息,一切似乎都是正确的。
另外,我已经尝试过一些事情,错误会在它找到的第一个 firstore 方法上发生变化 - 无论是 DocumentReference、FirestoreClient 还是其他任何方法。
感谢任何提前推荐的人。
【问题讨论】:
标签: java eclipse firebase gradle google-cloud-firestore