2016-04-12 116 views
0

我使用Dropbox SDK下載保存在保存在Dropbox中的文件。我使用AsynTask內部此方法:Android使用Dropbox Api java.lang.VerifyError:com/dropbox/client2/RESTUtility

@Override 
public void downloadData() { 
    String filePath = getApplicationContext().getFilesDir().getPath().toString() + "/routes.xlsx"; 
    File file = new File(filePath); 
    try { 
     FileOutputStream outputStream = new FileOutputStream(file); 
     DropboxAPI.DropboxFileInfo info = mDBApi.getFile("routes.xlsx", null, outputStream, null); 
     Log.i("DbExampleLog", "The file's rev is: " + info.getMetadata().rev); 
     RemoteResourcesLogic remoteResourcesLogic = new RemoteResourcesLogic(); 
     remoteResourcesLogic.read(filePath); 
    } catch (Exception e) { 
     Log.i("DbExampleLog", "Error getting folder"); 
    } 

} 

的問題是精確地:DropboxAPI.DropboxFileInfo信息= mDBApi.getFile( 「routes.xlsx」,NULL,OutputStream中,NULL);

我在libs文件夾中的所有neccessary的.jar:

  • 的HttpCore-4.0.1.jar
  • 的JUnit 4.10.jar
  • json_simple-1.1.jar
  • httpmime-4.0。 3.jar
  • 的HttpClient-4.0.3.jar
  • 的Dropbox,Android的SDK-1.6.3.jar
  • bcprov-jdk16-146.jar

和兩個罐子閱讀XSLX文件:

  • AA-POI 3.10分鐘-0.1.5.jar
  • AA-POI-OOXML-架構 - 3.10 - 減少 - 更多 - 0.1.5.jar

有人能幫助我嗎?

問候

FATAL EXCEPTION: AsyncTask #1 

Process: com.curiocity.android, PID: 28885 
java.lang.RuntimeException: An error occured while executing doInBackground() 
at android.os.AsyncTask$3.done(AsyncTask.java:300) 
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
Caused by: java.lang.VerifyError: com/dropbox/client2/RESTUtility 

at com.dropbox.client2.DropboxAPI.getFileStream(DropboxAPI.java:1544) 
at com.dropbox.client2.DropboxAPI.getFile(DropboxAPI.java:1497) 
at com.curiocity.admin.ImportRoutesActivity.downloadData(ImportRoutesActivity.java:111) 
at com.curiocity.admin.ImportRoutesActivity$DownloadData.doInBackground(ImportRoutesActivity.java:125) 
at com.curiocity.admin.ImportRoutesActivity$DownloadData.doInBackground(ImportRoutesActivity.java:121) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 

回答

0

按照documentation一個VerifyError表示:

Thrown when the VM notices that an attempt is made to load a class which does not pass the class verification phase.

在過去,我已經看到了這個時候出庫,例如,json_simple-1.1.jar,WASN」 t正確添加。你可以仔細檢查你已經安裝了dropbox-android-sdk-1.6.3.jar和json_simple-1.1.jar嗎?這些指令可以在這裏找到:

https://www.dropbox.com/developers-v1/core/sdks/android

如果您使用過Android Studio,請務必點擊「添加爲庫」兩種。

另外,還要注意對Dropbox的API應該以"/"啓動文件路徑,所以這行:

DropboxAPI.DropboxFileInfo info = mDBApi.getFile("routes.xlsx", null, outputStream, null);

應該是:

DropboxAPI.DropboxFileInfo info = mDBApi.getFile("/routes.xlsx", null, outputStream, null);

+0

感謝格雷格。我已將「/」添加到mDBApi.getFile(「routes.xlsx」,null,outputStream,null);在Android Studio中,我切換到Project視圖,並且可以看到libs文件夾,並且我看不到「json_simple-1.1.jar」和「dropbox-android-sdk-1.6.3.jar」的「添加爲庫」選項。你能幫我嗎? Regards – user2316075

+0

如果「添加爲庫」選項不存在,則可能已經完成。也許嘗試刪除並重新添加罐子? – Greg