Announcement Announcement Module
Collapse
No announcement yet.
Spring for Android does not run on JVM Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring for Android does not run on JVM

    Hi,
    I'm writing some tests for Spring for Android and I copied the sample code and the neccassary libs in my Java project but I always get the following error:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: android.util.Log.isLoggable(Ljava/lang/String;I)Z
    at android.util.Log.isLoggable(Native Method)
    at org.springframework.http.client.support.HttpAccess or.createRequest(HttpAccessor.java:85)
    at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:472)
    at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:439)
    at org.springframework.web.client.RestTemplate.getFor Object(RestTemplate.java:237)
    at Main.springTest(Main.java:67)
    at Main.main(Main.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main (AppMain.java:120)
    Here's the sample code:

    Code:
    private static void springTest() {
        // The connection URL
        String url = "https://ajax.googleapis.com/ajax/" +
                "services/search/web?v=1.0&q={query}";
    
        // Create a new RestTemplate instance
        RestTemplate restTemplate = new RestTemplate();
    
        // Add the String message converter
        restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
    
        // Make the HTTP GET request, marshaling the response to a String
        String result = restTemplate.getForObject(url, String.class, "Android"); // <-- Here raises the Exception!
    }
    I'm running this on Oracle JVM. Is maybe this the problem?

    Thanks in advance!
    Steffo

  • #2
    I'am not sure, but look at the URI you are trying to access. Which protocol is being used? It seems you have not configured RestTemplate for HTTPS. I have found this thread at stackoverflow, check it out:

    http://stackoverflow.com/questions/1...g-resttemplate

    If you created this just for trying

    Comment


    • #3
      If you are trying to build JVM based applications, please use RestTemplate available in the spring-web module of Spring Framework. Spring for Android is expecting an Android runtime. The error you are seeing is because android.util.Log cannot be found.

      Comment


      • #4
        Ok, thx for your reply!

        Best regards
        Steffo

        Comment

        Working...
        X