2014-03-26 161 views
1

我對java/Android開發非常陌生。我選擇的IDE是Android Studio。基本上我需要將圖像/視頻剪輯和音頻剪輯上傳到GCS。我實例化服務這樣
當我嘗試實例化GCS服務時出現java.lang.NoClassDefFoundError錯誤

" final GcsService gcsService = >GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());"
When I run the app I get the following error
java.lang.NoClassDefFoundError: com.google.appengine.api.utils.SystemProperty at >com.google.appengine.tools.cloudstorage.GcsServiceFactory.createRawGcsService(GcsServiceFact>ory.java:40) at >com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory>.java:34) at >com.horcu.lme.gavi.cloud.CloudPersister.downloadDataFromGcs(CloudPersister.java:30) at >com.horcu.lme.gavi.MainActivity$PlaceholderFragment.onCreateView(MainActivity.java:159)
The dependency section of my build.gradle file looks like this

dependencies { compile 'com.android.support:support-v4:19.0.1' compile 'com.android.support:appcompat-v7:19.0.1' compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.guava:guava-collections:[email protected]' compile 'com.google.appengine.tools:appengine-gcs-client:[email protected]' compile 'commons-io:commons-io:[email protected]'

}

正如你可以看到,我包括AppEngine上-GCS-客戶端jar文件,它編譯得很好,但崩潰在運行時。 任何人都可以提出一個解決這個問題嗎?

回答

1

這通常意味着您缺少依賴關係。請注意,GCS需要的不僅僅是appengine-gcs-client jar。首先,我認爲它需要joda-time.jar。

此外,使用API​​作爲應用程序引擎中的服務不可用,通常需要Google Java客戶端庫,那麼您有嗎?
https://code.google.com/p/google-api-java-client/

最後,我想指出,你有上面的錯誤是「com.google.appengine.api.utils.SystemProperty」,這實際上是應用程序引擎本身的一部分。你有應用引擎JAR的嗎?我沒有使用Android Studio,但我不希望你需要手動添加應用程序引擎JAR - 當你創建一個應該自動添加的應用程序引擎項目時。

如果你沒有與Android Studio結婚,你可能會考慮Eclipse + ADT,這些都是爲你完成的。谷歌已經表示,Android STudio將支持GAE,但它甚至沒有針對Android發佈,更不用說應用引擎。

+0

我導入我的應用程序到Eclipse,它的工作就像一個魅力。感謝一百萬人爲我節省了很多時間。 –

+0

我不得不回去使用Android Studio,同樣的問題仍然困擾着我。有沒有人成功地將gcs-client庫添加到Android Studio項目中? –

相關問題