java.lang.NoClassDefFoundError error when I try to

2019-08-09 05:09发布

问题:

I am very new to java/Android development. My IDE of choice is Android Studio. Essentially I need to upload images/vidoes clips and audio clips to GCS. I am instantiating the service like this

" 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'

}

As you can see I am including the appengine-gcs-client jar file and it compiles just fine but crashes at run-time. Can anyone suggest a fix for this?

回答1:

This usually means that you are missing dependencies. Note that GCS requires more then just the appengine-gcs-client jar. For one thing, I think it requires joda-time.jar.

Also, using the API's that are not available as services within app engine typically requires the Google Java client library, do you have that?
https://code.google.com/p/google-api-java-client/

Finally, I would note that the error you have above is for "com.google.appengine.api.utils.SystemProperty" which is actually part of app engine itself. Do you have the app engine JAR's? I haven't used Android Studio but I wouldn't expect you to have to add the app engine JAR's manually - when you created an app engine project that should have been added automatically.

If you aren't wed to Android Studio, you might want to consider Eclipse + ADT where all of this is done for you. Google has said that Android STudio will support GAE, but it's not even released for Android yet, let alone app engine.