Android错误:注释值不是允许的类型

时间:2020-06-21 13:57:43

标签: android notifications

我正在遵循一个教程来生成通知,但是出现错误annotation value not of an allowable type。我已经看到类似问题的答案,但无法解决我的问题。那么,有什么帮助吗?

public interface APIServices {

@Header(
        value = { // error is on this lin
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

@POST("fcm/send")
Call<MyResponse> sendNotification(@Body Sender body);

}

2 个答案:

答案 0 :(得分:1)

尝试替换

@Header(
        value = { // error is on this lin
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

@Headers({ 
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

答案 1 :(得分:0)

我建议从检查文件顶部的导入开始,并确保从想要的位置导入@Header和@POST批注。