android - 尝试实例化 GCS 服务时出现 java.lang.NoClassDefFoundError 错误

标签 android google-app-engine google-cloud-storage

我是 java/Android 开发的新手。我选择的 IDE 是 Android Studio。本质上,我需要将图像/视频剪辑和音频剪辑上传到 GCS。我正在像这样实例化服务

" 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:r03@jar' compile 'com.google.appengine.tools:appengine-gcs-client:0.3.3@jar' compile 'commons-io:commons-io:20030203.000550@jar'

}

如您所见,我包含了 appengine-gcs-client jar 文件,它编译得很好,但在运行时崩溃了。 谁能建议解决这个问题?

最佳答案

这通常意味着您缺少依赖项。请注意,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,所有这些都已为您完成。 Google 表示 Android STudio 将支持 GAE,但它甚至还没有针对 Android 发布,更不用说应用引擎了。

关于android - 尝试实例化 GCS 服务时出现 java.lang.NoClassDefFoundError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22673496/

相关文章:

java - 通过 Maven 或 Eclipse 使用和检查 Android 支持注释(无需 Android Studio)

google-app-engine - 如何使用 Python GCS JSON API 下载 Google Cloud 存储中单个 zip 文件中的所有对象

google-cloud-platform - 从 GCP 计算实例复制到存储桶时出现 AccessDeniendException

java - 如何使用 simple-xml 库解析 xml,其中数据是列表并由不同类型的列表组成?

android - 测试开发人员手机上的 GPS 坐标

google-app-engine - 应用引擎上的爬虫

google-app-engine - 将 Google Cloud Storage API 与 Go AppEngine 结合使用

javascript - firebase 函数中有没有办法删除与正则表达式匹配的存储文件?

android - 如何在android webview中播放wav格式的音频文件?

python - 我*必须*在我的数据库中存储第三方凭证。最好的办法?