简体   繁体   English

尝试实施Azure移动服务的Android格式错误的URL错误

[英]Android malformed URL error trying to implement Azure Mobile Service

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 . 我正在尝试使用Azure门户内部的文档(门户>移动服务> Android>连接现有Android应用程序)在Android应用程序中实现Azure移动服务,并且在尝试实例化时遇到Java格式错误的URL错误一个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 未处理的异常:java.net.MalformedURLException

I've added the buildscript and compile declarations in the project/app Gradle files. 我已经在project / app Gradle文件中添加了buildscript和compile声明。 Using version 2.0.3 of the SDK (tried using 2.0.2 as well). 使用SDK的2.0.3版本(也尝试使用2.0.2)。

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: 我要在该活动中声明一个私有成员来像这样持有MobileServiceClient:

private MobileServiceClient mClient;

Using Android Studio 1.3.2. 使用Android Studio 1.3.2。

The URL constructor has a checked MalformedUrlException URL 构造函数具有已检查的MalformedUrlException

You need to either add throws MalformedUrlException to your calling method, or wrap it in a try/catch: 您需要将throws MalformedUrlException添加到您的调用方法中,或将其包装在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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM