jclouds-android needs some assistance

12 views
Skip to first unread message

Mihai Campean

unread,
Dec 3, 2009, 12:18:06 PM12/3/09
to jclouds
Hi all,

I've managed to determine what caused my eclipse workspace to crash
when I wanted to add the jclouds core, the twitter module and their
dependencies to the jclouds-android Android application that I intend
to use as a demo of jclouds on Android. The problem was caused by
eclipse not having enough space to build the app and I solved it by
increasing the heap in eclipse.ini - see http://code.google.com/p/jclouds-android/wiki/EclipseSetup.
However, it seems we're not out of the woods yet. The code I am
using to connect to twitter in order to try to get the tweets, and
which looks like this:

TwitterClient tc = TwitterContextFactory.createContext(user,
password).getApi();
tc.getMyMentions();

crashes with the following stack trace:

12-03 17:08:49.532: ERROR/AndroidRuntime(713):
com.google.inject.ProvisionException: Guice provision errors:
12-03 17:08:49.532: ERROR/AndroidRuntime(713): 1) Error in custom
provider, java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.twitter.config.TwitterRestClientModule.provideAsyncClient
(Unknown Source)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.twitter.config.TwitterRestClientModule.provideAsyncClient
(Unknown Source)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): while locating
org.jclouds.twitter.TwitterAsyncClient
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.twitter.config.TwitterContextModule.provideContext(Unknown
Source)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.twitter.config.TwitterContextModule.provideContext(Unknown
Source)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): while locating
org.jclouds.rest.RestContext<org.jclouds.twitter.TwitterAsyncClient,
org.jclouds.twitter.TwitterClient>
12-03 17:08:49.532: ERROR/AndroidRuntime(713): 1 error
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:770)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:
792)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.rest.RestContextBuilder.buildContext
(RestContextBuilder.java:193)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
org.jclouds.twitter.TwitterContextFactory.createContext
(TwitterContextFactory.java:52)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.googlecode.jcloudsandroid.CloudTweet$1.onClick(CloudTweet.java:31)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.View.performClick(View.java:2179)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.View.onTouchEvent(View.java:3828)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.widget.TextView.onTouchEvent(TextView.java:6291)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.View.dispatchTouchEvent(View.java:3368)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent
(PhoneWindow.java:1197)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.app.Activity.dispatchTouchEvent(Activity.java:1993)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.os.Handler.dispatchMessage(Handler.java:99)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.os.Looper.loop(Looper.java:123)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
android.app.ActivityThread.main(ActivityThread.java:3948)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
java.lang.reflect.Method.invokeNative(Native Method)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
java.lang.reflect.Method.invoke(Method.java:521)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
dalvik.system.NativeStart.main(Native Method)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): Caused by:
java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderMethod.get(ProviderMethod.java:106)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InternalFactoryToProviderAdapter.get
(InternalFactoryToProviderAdapter.java:40)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call
(ProviderToInternalFactoryAdapter.java:43)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl.callInContext
(InjectorImpl.java:814)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderToInternalFactoryAdapter.get
(ProviderToInternalFactoryAdapter.java:40)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.Scopes$1$1.get(Scopes.java:63)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InternalFactoryToProviderAdapter.get
(InternalFactoryToProviderAdapter.java:40)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:
761)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl.callInContext
(InjectorImpl.java:814)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:757)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.spi.ProviderLookup$1.get(ProviderLookup.java:89)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderMethod.get(ProviderMethod.java:95)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InternalFactoryToProviderAdapter.get
(InternalFactoryToProviderAdapter.java:40)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call
(ProviderToInternalFactoryAdapter.java:43)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.InjectorImpl.callInContext
(InjectorImpl.java:814)
12-03 17:08:49.532: ERROR/AndroidRuntime(713): at
com.google.inject.internal.ProviderToInternalFactoryAdapter.get
(ProviderToInternalFactoryAdap

Since I have zero experience with Google guice and it looks like guice
is the culprit, I was hoping that some of you might be able to give me
some advice on this.

Thanks in advance,
Mihai

Ivan Meredith

unread,
Dec 3, 2009, 3:53:01 PM12/3/09
to jcl...@googlegroups.com
For a start you probably need google guice with no AOP.
http://code.google.com/p/google-guice/downloads/list. The regular one
will not work on Android

Now we don't want to use that in the regular jclouds dist I imagine,
as its not as fast, so just be aware of that. It also does not support
method interception which im not sure if jclouds does (I haven't seen
it yet though).

If you still have problems we may have to patch jclouds possibly.
> --
>
> You received this message because you are subscribed to the Google Groups "jclouds" group.
> To post to this group, send email to jcl...@googlegroups.com.
> To unsubscribe from this group, send email to jclouds+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jclouds?hl=en.
>
>
>

Mihai Campean

unread,
Dec 4, 2009, 3:06:22 AM12/4/09
to jcl...@googlegroups.com
Hi Ivan,

I already used a no aop built version of guice - at least that's
what I think I did. I will checkout the steps in order to build guice
with no aop to see if I missed something.

Thanks for the info,
Mihai

Ivan Meredith

unread,
Dec 4, 2009, 3:08:47 AM12/4/09
to jcl...@googlegroups.com
The other thing ive done in the past is to get the source for a
library and compile it directly into the app.

Mihai Campean

unread,
Dec 4, 2009, 3:28:37 AM12/4/09
to jcl...@googlegroups.com
Thanks for the suggestion Ivan, that will probably be a step to do,
however taking into account the fact that jclouds has quite a few
dependencies, this is not a desired approach, at least not for all
dependencies. We might try to compile the sources for the troublesome
ones though.

Cheers,
Mihai

Adrian Cole

unread,
Dec 4, 2009, 6:46:14 PM12/4/09
to jcl...@googlegroups.com
Like other things, we can eliminate Guice in general as a problem by creating a simple thing that uses Guice from Android.

Like,

      System.out.println(Guice.createInjector(new AbstractModule() {
         public void configure() {
            bind(String.class).toInstance("hello world");
         }
      }).getInstance(String.class));


Try that!
-Adrian

Mihai Campean

unread,
Dec 5, 2009, 7:59:55 AM12/5/09
to jcl...@googlegroups.com
Hi Adrian,

I've just tried the code you suggested and it works like a charm, so
it must be something else then. I'll do some more debugging now to see
if I can find a cause.

Cheers,
Mihai

Mihai Campean

unread,
Dec 5, 2009, 10:09:24 AM12/5/09
to jcl...@googlegroups.com
This seems to be some sort of a build problem. I am going to rebuild
jclouds and try again. If this doesn't work, I am going to try to dex
all the jclouds libraries and the dependencies.

Cheers,
Mihai

Mihai Campean

unread,
Dec 6, 2009, 8:36:16 AM12/6/09
to jcl...@googlegroups.com
Hi guys,

I have arrived to a hypothesis regarding the error that I presented
earlier. I noticed that I get a warning in the Android eclipse console
after the build of jclouds-android completes, and the warning looks
something like this:

warning: Ignoring InnerClasses attribute for an anonymous inner class
that doesn't come with an associated EnclosingMethod attribute. (This
class was probably produced by a broken compiler.)

After doing some research on the android-developers google group on
this error, it seems that it occurs when using third party jars in
your Android application, that use inner classes and were not compiled
with the Android compiler. Normally this shouldn't cause issues unless
you use reflection on these inner classes (see here
http://groups.google.com/group/android-developers/browse_thread/thread/e7fce56cec444093/75416717ce32dfde?hl=en&lnk=gst&q=EnclosingMethod&pli=1),
which I believe in our case is a problem.
The suggestions for solving this kind of problem seem to involve
compiling the sources of the troublesome libraries using the Android
dex compiler, of course handling whatever compiling errors might
occur.
Taking all this stuff into consideration, I believe that the next
course of action for porting jclouds to Android is to have jclouds
compiled with the dex compiler, solving whatever issues may arrive
from this. This also involves taking each dependency, getting it's
sources and compiling it using the dex compiler, to make sure we're
avoiding further issues (looks like we can't escape what we've
feared).
My next step will be to try writing an ant script or some similar
script that will help us compile the libraries easier. Once I do that
and write up some instructions on how to use it in the jclouds-android
project wiki, I'm going to rely on your kindness in helping me compile
all the dependencies from source one by one, first starting with the
ones that are suspects of these warnings.

Cheers,
Mihai

P.S. Mike, as I remember, you said you tried this at one point, I
would appreciate your input and some scripts you may have.

Adrian Cole

unread,
Dec 6, 2009, 11:43:33 AM12/6/09
to jcl...@googlegroups.com
Very interesting, Mihai.

Once we get this process together, I'm sure we can add a job to hudson that precompiles everything android into a handy jar.

Thanks, this looks like hard work!
-Adrian

Mihai Campean

unread,
Dec 7, 2009, 2:53:47 AM12/7/09
to jcl...@googlegroups.com
I also think that we should be able to work out something.
Meanwhile, I would like to know if anyone else had experience with
building scripts for compiling third party libraries from source for
Android.
Any input would be most valuable.

Cheers,
Mihai
Reply all
Reply to author
Forward
0 new messages