You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by azq <an...@gmail.com> on 2014/10/06 16:55:29 UTC

Is jclouds developer-friendly for Android ?

Hi, everyone,

My name is 安仲奇.

I recently started using jclouds to develop clients for the internal
OpenStack platform of my lab, and jclouds really helped me a lot, and
everything worked fine in my Java Swing client.

I ran into some problems when I tried to do the same on the Android
platform, such as:

When building a Keystone API (`newBuilder("openstack-keystone")`), an
exception of

```
java.util.NoSuchElementException: key [openstack-keystone] not in the
list of providers or apis: {}
```

was throwed out.

When getting the jclouds version (`JcloudsVersion.get()`), an exception
of

```
java.lang.NullPointerException:
META-INF/maven/org.apache.jclouds/jclouds-core/pom.properties
```

was catched.

I'm using the `1.8.0-SNAPSHOT` jar files, and I've imported every
dependency jar downloaded by Maven to the `lib` folder of my Eclipse
projcet.

So, any ideas about what could be the problem? Is jclouds compatible
with the Android platform?

Best wishes!

---

anzhongqi
High Performance Computer Research Center
Institute of Computing Technology, Chinese Academy of Sciences


Re: Is jclouds developer-friendly for Android ?

Posted by Andrew Phillips <an...@apache.org>.
> So, any ideas about what could be the problem? Is jclouds compatible
> with the Android platform?

On this specific point, which seems to be related to the way jclouds  
is trying to use ServiceLoader to load the appropriate implementation  
class for an API or provider:

http://stackoverflow.com/questions/5760607/using-serviceloader-on-android

Regards

ap

Re: Is jclouds developer-friendly for Android ?

Posted by Ignasi Barrera <na...@apache.org>.
Hi,

If I'm not wrong Android uses a different implementation of the Java
ServiceLoader, and that might be causing the issue. Could you try
creating the context by directly passing an instance of the provider
metadata? Something like:

ContextBuilder.newBuilder(new KeystoneApiMetadata())
...

This will bypass the ServiceLoader lookup and instantiate directly the
context with the API you want to use. You may change the metadata
class for whatever ApiMetadata or ProviderMetadata you want to use.

Also, I'd recommend you configure the context to use the OkHttp driver
[1], as it is an HTTP library specifically designed to work on Android
devices.


HTH!

I.


[1] https://github.com/jclouds/jclouds/tree/master/drivers/okhttp

On 6 October 2014 16:55, azq <an...@gmail.com> wrote:
> Hi, everyone,
>
> My name is 安仲奇.
>
> I recently started using jclouds to develop clients for the internal
> OpenStack platform of my lab, and jclouds really helped me a lot, and
> everything worked fine in my Java Swing client.
>
> I ran into some problems when I tried to do the same on the Android
> platform, such as:
>
> When building a Keystone API (`newBuilder("openstack-keystone")`), an
> exception of
>
> ```
>     java.util.NoSuchElementException: key [openstack-keystone] not in the
> list of providers or apis: {}
> ```
>
> was throwed out.
>
> When getting the jclouds version (`JcloudsVersion.get()`), an exception
> of
>
> ```
>     java.lang.NullPointerException:
> META-INF/maven/org.apache.jclouds/jclouds-core/pom.properties
> ```
>
> was catched.
>
> I'm using the `1.8.0-SNAPSHOT` jar files, and I've imported every
> dependency jar downloaded by Maven to the `lib` folder of my Eclipse
> projcet.
>
> So, any ideas about what could be the problem? Is jclouds compatible
> with the Android platform?
>
> Best wishes!
>
> ---
>
> anzhongqi
> High Performance Computer Research Center
> Institute of Computing Technology, Chinese Academy of Sciences
>

Re: Is jclouds developer-friendly for Android ?

Posted by Adrian Cole <ad...@gmail.com>.
Let's bump this to a jira and the dev list. There's grey area here.

https://issues.apache.org/jira/browse/JCLOUDS-747

-A

On Mon, Oct 6, 2014 at 10:20 AM, Andrew Gaul <ga...@apache.org> wrote:
> Modern Android supports modern Java language features:
>
> http://stackoverflow.com/questions/20480090/does-android-support-jdk-6-or-7
>
> If someone in the community contributes well-scoped patches to allow
> jclouds 1.8.x to work better on older Android we can merge those but
> otherwise jclouds 2.0 should remain Java 7-only for its
> previously-discussed benefits.
>
> On Mon, Oct 06, 2014 at 08:57:19AM -0700, Adrian Cole wrote:
>> Actually, it seems the 2.0 branch has started to use java 7 constructs
>> internally, which will make jclouds definitely incompatible with android.
>>
>> For example, it is ok for code to expose alternate paths that use java 7 or
>> even 8 (ex how okio still works is that these methods are not called in
>> android and therefore ignored).  However, core shared code can't and still
>> remain android compatible.
>>
>> Copying in developer list just so folks know the impact of using trt with
>> resources :) If we switch to a manner in which java 7 or 8 is optional (no
>> pun intended), android still has a chance.
>>
>> -A
>
> --
> Andrew Gaul
> http://gaul.org/

Re: Is jclouds developer-friendly for Android ?

Posted by Adrian Cole <ad...@gmail.com>.
Let's bump this to a jira and the dev list. There's grey area here.

https://issues.apache.org/jira/browse/JCLOUDS-747

-A

On Mon, Oct 6, 2014 at 10:20 AM, Andrew Gaul <ga...@apache.org> wrote:
> Modern Android supports modern Java language features:
>
> http://stackoverflow.com/questions/20480090/does-android-support-jdk-6-or-7
>
> If someone in the community contributes well-scoped patches to allow
> jclouds 1.8.x to work better on older Android we can merge those but
> otherwise jclouds 2.0 should remain Java 7-only for its
> previously-discussed benefits.
>
> On Mon, Oct 06, 2014 at 08:57:19AM -0700, Adrian Cole wrote:
>> Actually, it seems the 2.0 branch has started to use java 7 constructs
>> internally, which will make jclouds definitely incompatible with android.
>>
>> For example, it is ok for code to expose alternate paths that use java 7 or
>> even 8 (ex how okio still works is that these methods are not called in
>> android and therefore ignored).  However, core shared code can't and still
>> remain android compatible.
>>
>> Copying in developer list just so folks know the impact of using trt with
>> resources :) If we switch to a manner in which java 7 or 8 is optional (no
>> pun intended), android still has a chance.
>>
>> -A
>
> --
> Andrew Gaul
> http://gaul.org/

Re: Is jclouds developer-friendly for Android ?

Posted by Andrew Gaul <ga...@apache.org>.
Modern Android supports modern Java language features:

http://stackoverflow.com/questions/20480090/does-android-support-jdk-6-or-7

If someone in the community contributes well-scoped patches to allow
jclouds 1.8.x to work better on older Android we can merge those but
otherwise jclouds 2.0 should remain Java 7-only for its
previously-discussed benefits.

On Mon, Oct 06, 2014 at 08:57:19AM -0700, Adrian Cole wrote:
> Actually, it seems the 2.0 branch has started to use java 7 constructs
> internally, which will make jclouds definitely incompatible with android.
> 
> For example, it is ok for code to expose alternate paths that use java 7 or
> even 8 (ex how okio still works is that these methods are not called in
> android and therefore ignored).  However, core shared code can't and still
> remain android compatible.
> 
> Copying in developer list just so folks know the impact of using trt with
> resources :) If we switch to a manner in which java 7 or 8 is optional (no
> pun intended), android still has a chance.
> 
> -A

-- 
Andrew Gaul
http://gaul.org/

Re: Is jclouds developer-friendly for Android ?

Posted by Andrew Gaul <ga...@apache.org>.
Modern Android supports modern Java language features:

http://stackoverflow.com/questions/20480090/does-android-support-jdk-6-or-7

If someone in the community contributes well-scoped patches to allow
jclouds 1.8.x to work better on older Android we can merge those but
otherwise jclouds 2.0 should remain Java 7-only for its
previously-discussed benefits.

On Mon, Oct 06, 2014 at 08:57:19AM -0700, Adrian Cole wrote:
> Actually, it seems the 2.0 branch has started to use java 7 constructs
> internally, which will make jclouds definitely incompatible with android.
> 
> For example, it is ok for code to expose alternate paths that use java 7 or
> even 8 (ex how okio still works is that these methods are not called in
> android and therefore ignored).  However, core shared code can't and still
> remain android compatible.
> 
> Copying in developer list just so folks know the impact of using trt with
> resources :) If we switch to a manner in which java 7 or 8 is optional (no
> pun intended), android still has a chance.
> 
> -A

-- 
Andrew Gaul
http://gaul.org/

Re: Is jclouds developer-friendly for Android ?

Posted by Adrian Cole <ad...@gmail.com>.
Actually, it seems the 2.0 branch has started to use java 7 constructs
internally, which will make jclouds definitely incompatible with android.

For example, it is ok for code to expose alternate paths that use java 7 or
even 8 (ex how okio still works is that these methods are not called in
android and therefore ignored).  However, core shared code can't and still
remain android compatible.

Copying in developer list just so folks know the impact of using trt with
resources :) If we switch to a manner in which java 7 or 8 is optional (no
pun intended), android still has a chance.

-A

Re: Is jclouds developer-friendly for Android ?

Posted by Adrian Cole <ad...@gmail.com>.
Actually, it seems the 2.0 branch has started to use java 7 constructs
internally, which will make jclouds definitely incompatible with android.

For example, it is ok for code to expose alternate paths that use java 7 or
even 8 (ex how okio still works is that these methods are not called in
android and therefore ignored).  However, core shared code can't and still
remain android compatible.

Copying in developer list just so folks know the impact of using trt with
resources :) If we switch to a manner in which java 7 or 8 is optional (no
pun intended), android still has a chance.

-A

Re: Is jclouds developer-friendly for Android ?

Posted by Adrian Cole <ad...@gmail.com>.
Hi, 安仲奇!

So, I wouldn't say jclouds is android friendly, yet. It still uses a lot of
reflection and we don't have a test module to ensure any level of
compatibility.

That said, we can improve upon this over time for sure. First steps I would
take is to use 1.8.1 (coming out this week), the okhttp driver, and use the
ApiMetadata arg to ContextBuilder (ex. newBuilder (new NovaApiMetadata())

Even better, open a jira and help us track progress as we can certainly
make things better (if still a work in progress) for 2.0

-A
On Oct 6, 2014 7:56 AM, "azq" <an...@gmail.com> wrote:

>  Hi, everyone,
>
> My name is 安仲奇.
>
> I recently started using jclouds to develop clients for the internal
> OpenStack platform of my lab, and jclouds really helped me a lot, and
> everything worked fine in my Java Swing client.
>
> I ran into some problems when I tried to do the same on the Android
> platform, such as:
>
> When building a Keystone API (`newBuilder("openstack-keystone")`), an
> exception of
>
> ```
>     java.util.NoSuchElementException: key [openstack-keystone] not in the
> list of providers or apis: {}
> ```
>
> was throwed out.
>
> When getting the jclouds version (`JcloudsVersion.get()`), an exception
> of
>
> ```
>     java.lang.NullPointerException:
> META-INF/maven/org.apache.jclouds/jclouds-core/pom.properties
> ```
>
> was catched.
>
> I'm using the `1.8.0-SNAPSHOT` jar files, and I've imported every
> dependency jar downloaded by Maven to the `lib` folder of my Eclipse
> projcet.
>
> So, any ideas about what could be the problem? Is jclouds compatible
> with the Android platform?
>
> Best wishes!
>
> ---
>
> anzhongqi
> High Performance Computer Research Center
> Institute of Computing Technology, Chinese Academy of Sciences
>
>