Azure / azure-storage-android

Microsoft Azure Storage Library for Android
Apache License 2.0
81 stars 47 forks source link

container.CreateIfNotExists() throws NullReferenceException #1

Closed padjiwib-zz closed 9 years ago

padjiwib-zz commented 10 years ago

I tried to use the code snippet on your documentation.

        CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
        CloudBlobClient serviceClient = account.createCloudBlobClient();

        // Container name must be lower case.
        CloudBlobContainer container = serviceClient.getContainerReference("myimages");
        container.createIfNotExists();

It threw NullReferenceException while calling container.createIfNotExists(). I'm quite sure I have a valid storage account.

Thanks for looking, Peter

emgerner-msft commented 10 years ago

Hi Peter,

Thanks for reporting this! I ran some tests and the sample snippet provided and was not able to reproduce the issue. Could you provide some additional information? A stack trace, the version of Android you’re running on and whether you are using an emulator or a device would be most useful. Information on the setup of your Android project might also help.

Thanks, Emily

sharjeel-ahmed commented 10 years ago

I have the exact same problem. It returns a null pointer exception. Trying to debug more.

Let me know if you need any specific info.

Edit: Okie i figured out the problem, the exception comes when you call the code from the Main Thread[UI Thread] You need to call the code from a new Thread or Async Task. That solves the problem.

But the bug is that it throws a nullreferenceexception rather than a networkonmainthreadexception. This needs to be fixed.

emgerner-msft commented 9 years ago

We've reproduced the issue, added it to our backlog, and will update this thread when the fix is in. Thanks for the edit/update you provided - this made the repro much easier.

sharjeel-ahmed commented 9 years ago

No problem, I can edit it if you want me too :)

emgerner-msft commented 9 years ago

We've released a new version of the library (0.3.1) to address this issue. You should now receive the correct error message.