問題描述
在我的 Android 應用程序中,我使用 DynamoDb.我創建了一個類,它與一個數據庫表映射.應用程序在調試中正常運行.但是如果我導出 apk 并運行應用程序,我會得到 DynamoDbMapperException:
In my android app, I use DynamoDb. I create a class, which is mapped with a table of database. App runs normally in debug. But if I export apk and run app, I get the DynamoDbMapperException:
Caused by: com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMappingException: No method annotated with interface com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBHashKey for class class com.example.myclass.
我使用 Eclipse 和 proguard 來導出 apk.我猜 proguard 會導致問題,因為沒有 proguard 的 apk 可以正常工作.這是我的 Proguard 配置:
I use Eclipse and proguard to export apk. I guess proguard causes the problem, because the apk without proguard works fine. Here is my Proguard config:
-keepattributes *Annotation*
-keep public class com.example.myclass
請幫幫我!我不知道如何解決這個問題.
Please help me! I don't know how to solve the problem.
推薦答案
你使用的是 DynamoDB 表嗎?
Are you using a DynamoDB table?
你需要一個類的哈希鍵,你應該用@DynamoDBHashKey
注釋字段,你是否不小心將它注釋為@DynamoDBIndexHashKey
?如果是這樣,你應該把它改回來.
You need to have a hash key for the class, you should annotate the field with @DynamoDBHashKey
, do you accidentally annotated it as @DynamoDBIndexHashKey
? If so, you should change it back.
類似的參考可以在這里找到
A similar reference can be found here
Android Amazon DynamoDb 基本操作錯誤
嘗試改變
-keep public class com.example.myclass
到
-keep public class com.example.myclass {
*;
}
這篇關于DynamoDbMapperException:沒有方法注釋?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!