如何使用Gradle添加Firebase EventViewer?

时间:2017-07-07 00:22:51

标签: java firebase gradle firebase-realtime-database classnotfoundexception

使用understanding工作com.google.firebase.database.ValueEventListener是运行时依赖项,如何使用Gradle将其添加到类路径中?

thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ gradle jar

BUILD SUCCESSFUL in 33s
3 actionable tasks: 2 executed, 1 up-to-date
thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ java -jar build/libs/Firebase.jar 
Jul 06, 2017 5:09:06 PM net.bounceme.dur.firebase.Main main
INFO: init..
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/firebase/database/ValueEventListener
    at net.bounceme.dur.firebase.Main.<init>(Main.java:13)
    at net.bounceme.dur.firebase.Main.main(Main.java:17)
Caused by: java.lang.ClassNotFoundException: com.google.firebase.database.ValueEventListener
    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)
    ... 2 more
thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ jar -tf build/libs/Firebase.jar 
META-INF/
META-INF/MANIFEST.MF
net/
net/bounceme/
net/bounceme/dur/
net/bounceme/dur/firebase/
net/bounceme/dur/firebase/PropertiesHelper.class
net/bounceme/dur/firebase/FirebaseQuery.class
net/bounceme/dur/firebase/FirebaseAdd.class
net/bounceme/dur/firebase/UserHelper.class
net/bounceme/dur/firebase/Main.class
net/bounceme/dur/firebase/User.class
net/bounceme/dur/firebase/FirebaseQuery$1.class
firebase.json
firebase.properties
dur/
dur/bounceme/
dur/bounceme/net/
dur/bounceme/net/firebase/
thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ tree build/libs/
build/libs/
├── dur
│   └── bounceme
│       └── net
│           └── firebase
│               ├── FirebaseAdd.class
│               ├── FirebaseQuery$1.class
│               ├── FirebaseQuery.class
│               ├── Main.class
│               ├── PropertiesHelper.class
│               ├── User.class
│               └── UserHelper.class
├── Firebase.jar
└── META-INF
    └── MANIFEST.MF

5 directories, 9 files
thufir@doge:~/NetBeansProjects/Firebase$ 
thufir@doge:~/NetBeansProjects/Firebase$ cat build.gradle
plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
    id 'application'
}

buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}

jar {
    manifest {
        attributes 'Main-Class': 'net.bounceme.dur.firebase.Main'
    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])

    // https://mvnrepository.com/artifact/com.google.firebase/firebase-admin
    compile group: 'com.google.firebase', name: 'firebase-admin', version: '5.2.0'

    // https://mvnrepository.com/artifact/com.google.firebase/firebase-server-sdk
    compile group: 'com.google.firebase', name: 'firebase-server-sdk', version: '3.0.3'

    // https://mvnrepository.com/artifact/com.firebase/firebase-client-jvm
    compile group: 'com.firebase', name: 'firebase-client-jvm', version: '2.5.2'
}
thufir@doge:~/NetBeansProjects/Firebase$ 

another问题相关。

0 个答案:

没有答案