1. 程式人生 > >Could not find class com.google.gson.Gson

Could not find class com.google.gson.Gson

解析json jar ont .class exc 保存 題解 clean ext

在Android開發中使用gson解析json字符串,出現異常:java.lang.classnotfoundexception:com.google.gson.Gson。解決方案如下:

這個異常的怪異之處在於,你可能已經將google的gson包導入了項目,但是為什麽應用程序仍然報錯,說找不到這個類?

  • 2

    原因在於此包只是導入了項目,但是並沒有打包到應用程序中,所以應用運行的時候會找不到這個包。

  • 3

    解決方案為:右擊項目->buildpath->config build path->order and export->勾選 gson-x.x.x.jar->保存設置,clean 項目並重新編譯運行。

    發現問題解決!

Could not find class com.google.gson.Gson