Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin java.lang.NoClassDefFoundError:com/google/api/core/ApiFuture_Kotlin_Google Api_Aws Lambda_Firebase Admin - Fatal编程技术网

Kotlin java.lang.NoClassDefFoundError:com/google/api/core/ApiFuture

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() .

我已成功地将firebase admin添加到我的kotlin jvm后端代码中,我可以使用以下命令成功发送推送通知:

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)
    }
}