2013-02-06 46 views
0

我已經集成谷歌驅動器在我的Android應用程序,當我調試設備上的應用程序與Android版本2.3.6,我得到ClassNotFoundException的,當我把這個:谷歌驅動器爲gettoken類未發現異常

mCredential.getToken(); 

其中mCredential設置這樣的:

mCredential = GoogleAccountCredential.usingOAuth2(context, DriveScopes.DRIVE); 

我看到在我的Debug標籤:

Thread [<13> Thread-15] (Suspended (exception ClassNotFoundException)) 
<VM does not provide monitor information> 
PathClassLoader.findClass(String) line: 240 
PathClassLoader(ClassLoader).loadClass(String, boolean) line: 551 
PathClassLoader(ClassLoader).loadClass(String) line: 511  
GoogleAuthUtil.f(Context) line: not available 
GoogleAuthUtil.getToken(Context, String, String, Bundle) line: not available  
GoogleAuthUtil.getToken(Context, String, String) line: not available  
GoogleAccountCredential.getToken() line: 192  
GoogleDrive.checkIfUserIsAuthenticated(Activity, boolean) line: 411 
GoogleDrive.access$4(GoogleDrive, Activity, boolean) line: 403 
GoogleDrive$1.run() line: 98 

有人可以幫我嗎?

回答

0

我知道這是一個古老的問題,但我也把頭髮拉過來。對我來說,ClassNotFoundException是因爲缺少字符串資源。顯然,Google Play服務包含資源,必須將其導入爲庫項目,而不是僅將.jar作爲依賴項添加。在Eclipse中這樣做的說明如下:http://developer.android.com/google/play-services/setup.html

一旦我完成這些指令,我得到一個構建錯誤,指出多個指定了dexed的庫包含某些類或類似的東西。這個錯誤原來是因爲我現在有兩個引用google-play-services.jar。要修復該錯誤,請在項目資源管理器視圖下,右鍵單擊bin目錄並單擊刪除。這將擺脫與google-play-services.jar的多個副本dexedLibs文件夾。此時,我在我的項目的根目錄中引用了google-play-services.jar,並且在「Android Dependencies」下也有引用。我右鍵單擊我的項目根目錄中的引用,然後轉到構建路徑 - >從構建路徑中移除以擺脫它。