Kotlin java.lang.NoClassDefFoundError:com/google/api/core/ApiFuture
我已成功地将firebase admin添加到我的kotlin jvm后端代码中,我可以使用以下命令成功发送推送通知:Kotlin java.lang.NoClassDefFoundError:com/google/api/core/ApiFuture,kotlin,google-api,aws-lambda,firebase-admin,Kotlin,Google Api,Aws Lambda,Firebase Admin,我已成功地将firebase admin添加到我的kotlin jvm后端代码中,我可以使用以下命令成功发送推送通知: object FirebaseUtils { init { val credentials = GoogleCredentials.fromStream(Gson().toJson(FIREBASECREDIENTIALS).byteInputStream()) val options = FirebaseOptions.Builder() .
object FirebaseUtils {
init {
val credentials = GoogleCredentials.fromStream(Gson().toJson(FIREBASECREDIENTIALS).byteInputStream())
val options = FirebaseOptions.Builder()
.setCredentials(credentials)
.setDatabaseUrl("url")
.build()
FirebaseApp.initializeApp(options)
}
fun sendPushNotification(registrationToken:String,notificationTitle:String,notificationMessage:String){
val messageBuilder = Message.builder()
.setNotification(Notification(notificationTitle,notificationMessage))
.setToken(registrationToken)
val message = messageBuilder.build()
// Send a message to the device corresponding to the provided
// registration token.
val response = FirebaseMessaging.getInstance().send(message)
// Response is a message ID string.
println("Successfully sent message: $response")
}}
发送:
FirebaseUtils.sendPushNotification(registrationToken, ,"testTitle","testMessage")
但是当我把它上传到AWS Lamda时,我每次调用它都会得到这个异常
com/google/api/core/ApiFuture: java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError: com/google/api/core/ApiFuture
at utils.FirebaseUtils.<clinit>(FirebaseUtils.kt:29)
at lamdas.CourseManagerLambda.handleRequest(CourseManagerLambda.kt:57)
我正在构建我上传到AWS的zip,就像这样
task buildDist(type: Zip) {
appendix = "dist"
from sourceSets.main.output
from configurations.runtimeClasspath.findAll {
it.name.endsWith("jar")
}.collect {
zipTree(it)
}
}
由于某些原因,一些依赖项在运行时丢失了,所以我切换到使用生成胖罐子,现在一切正常
task buildDist(type: Zip) {
appendix = "dist"
from sourceSets.main.output
from configurations.runtimeClasspath.findAll {
it.name.endsWith("jar")
}.collect {
zipTree(it)
}
}