Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

NPE on Android #221

Closed
GoogleCodeExporter opened this issue Apr 6, 2015 · 8 comments
Closed

NPE on Android #221

GoogleCodeExporter opened this issue Apr 6, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a default Android application
2. Add <uses-permission android:name="android.permission.INTERNET" /> to
manifest
3. Inside the onCreate function call the following test code:

try
{
  Sync sync = new Sync();
  sync.test();
  sync.test();
}
catch (Exception e)
{
  e.printStackTrace();
}

with the class Sync looking like this:

import java.net.URL;
import java.util.List;
import android.util.Log;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.data.spreadsheet.*;


class Sync
{
    private SpreadsheetService  service;

    Sync() throws Exception
    {
        service = new SpreadsheetService("sync");
        service.setUserCredentials( <username>, <password>);
    }

    void test() throws Exception
    {
        log("TEST");

        URL metafeedUrl = new
URL("http://spreadsheets.google.com/feeds/spreadsheets/private/full");
        SpreadsheetFeed feed = service.getFeed(metafeedUrl, SpreadsheetFeed.class);
        List<SpreadsheetEntry> spreadsheets = feed.getEntries();
        for (int i = 0; i < spreadsheets.size(); i++)
        {
            SpreadsheetEntry entry = spreadsheets.get(i);
            log(entry.getTitle().getPlainText());
        }
    }

    private void log(String string)
    {
        Log.i("Sync", string);
    }
}

== What is the expected output? What do you see instead? ==

Expect to see (in Eclipse LogCat)

TEST
<list of spreadsheets>
TEST
<list of spreadsheets>

Instead get

TEST
<list of spreadsheets>
TEST
java.lang.NullPointerException
 at com.google.gdata.wireformats.AltRegistry.lookupType(AltRegistry.java:190)
 at com.google.gdata.client.Service.parseResponseData(Service.java:1860)
 at com.google.gdata.client.Service.getFeed(Service.java:1054)
 at com.google.gdata.client.Service.getFeed(Service.java:916)
 at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631)
 at com.google.gdata.client.Service.getFeed(Service.java:935)

where it calls

 SpreadsheetFeed feed = service.getFeed(metafeedUrl, SpreadsheetFeed.class);


== What version of the product are you using? On what operating system? ==

Android 1.5
gdata-base-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
google-collect-1.0-rc5.jar



Original issue reported on code.google.com by Jez.Ch...@gmail.com on 28 Dec 2009 at 4:11

@GoogleCodeExporter
Copy link
Author

Note that the equivalent code cut'n'pasted into a standard Java application 
with the
same libraries works fine.

Original comment by Jez.Ch...@gmail.com on 28 Dec 2009 at 4:22

@GoogleCodeExporter
Copy link
Author

The java client lib is not supported in android.  There are several technical 
differences 
between davlik jdk and desktop jdk which prevents the desktop jdk from working 
correctly in android platform.    There may be a android specific client 
library in the 
future., but its not available now.

Original comment by vbarat...@gmail.com on 29 Dec 2009 at 3:08

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

Do you know what is needed or how much work is involved? If the alternative is 
to
write/use another API, I'd prefer to help fixing what you guys have.

Original comment by Jez.Ch...@gmail.com on 4 Jan 2010 at 8:48

@GoogleCodeExporter
Copy link
Author

We are currently aware of this issue and are working on a android specific SDK 
(totally different from desktop one).  There are several issues, and key ones 
are 
related to performance and memory.  Desktop sdk is optimized for performance, 
but 
android one needs to be optimized for low memory footprint.  Unfortunately i 
donno 
when this android sdk will be available.

In the meantime, if you cannot wait and need to hack around, you may be able to 
reference some of the android specific code that exists in 1.5 
(com.google.android.gdata or com.google.wireless.gdata).

Note: This is a hack and is not a supported API and the signature and future 
support 
may change.  

see: http://www.androidjavadoc.com/m5-rc15/index.html

Original comment by vbarat...@gmail.com on 4 Jan 2010 at 9:16

@GoogleCodeExporter
Copy link
Author

Thanks for the response, I'll see if the unsupported API does enough.

Original comment by Jez.Ch...@gmail.com on 4 Jan 2010 at 9:26

@GoogleCodeExporter
Copy link
Author

I'm facing the same issue when I try get retrieve the ACL feed using 
"AclFeed aclFeed = service.getFeed(new URL(link.getHref()),AclFeed.class); "

Reading the above comments I downloaded "gdata-android-2.2.1-alpha" but there 
are hardly any classes in Calendar jar folder. 

I had downloaded the jar from the following location : 
http://gdata-java-client.googlecode.com/files/gdata-android-2.2.1-alpha.zip

Do I need to download from some other location?
Or are there any workarounds to fix the above mentioned issue.

Please suggest.

Original comment by tushar.m...@gmail.com on 12 Aug 2010 at 6:41

@GoogleCodeExporter
Copy link
Author

Please instead take a look a the new client project google-api-java-client 
which is backwards compatible with gdata-android-2.2-alpha at:

http://code.google.com/p/google-api-java-client/

Original comment by yan...@google.com on 12 Aug 2010 at 2:52

@GoogleCodeExporter
Copy link
Author

Issue 226 has been merged into this issue.

Original comment by yan...@google.com on 12 Aug 2010 at 2:54

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant