0

I'm trying to implement an Azure Mobile Service in an Android app, using the documentation from inside the Azure portal (Portal > Mobile Service > Android > Connect Existing Android App), and am running into the java malformed URL error when trying to instantiate a MobileServiceClient.

Code that is throwing the error:

mClient = new MobileServiceClient( "https://myurl.azure-mobile.net/", "my_secret_squirrel_key", this ); 

The compiler is throwing this error:

Unhandled exception:java.net.MalformedURLException

I've added the buildscript and compile declarations in the project/app Gradle files. Using version 2.0.3 of the SDK (tried using 2.0.2 as well).

I've added permissions to the manifest file, too:

<uses-permission android:name="android.permission.INTERNET" /> 

The activity I'm using this in is importing the mobile services library:

import com.microsoft.windowsazure.mobileservices.*; 

And I'm declaring a private member in that same activity to hold the MobileServiceClient like so:

private MobileServiceClient mClient; 

Using Android Studio 1.3.2.

1

1 Answer 1

3

The URL constructor has a checked MalformedUrlException

You need to either add throws MalformedUrlException to your calling method, or wrap it in a try/catch:

try {     mClient = new MobileServiceClient( "https://myurl.azure-mobile.net/", "my_secret_squirrel_key",         this); } catch(MalformedUrlException ex) {     Log.e("Service URL was malformed!", ex); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.