安卓5.0磨损无法解析主机(HTTP,AsyncClient ETC.) [英] android Wear 5.0 can't resolve host (Http , AsyncClient ETC. )

查看:598
本文介绍了安卓5.0磨损无法解析主机(HTTP,AsyncClient ETC.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了Android Wear应用也SDK是4.4AW。完成之后,applitacion我对新的Andr​​oid SDK的磨损是5.0.1仿真器和motorola360(与5.0.1)测试,然后我recived这errror(显示在下面的)

信息和:


  

无法解析主机


详细讯息:


  

无法解析主机URL:没有与主机名关联的地址


应用程序完美的作品上4.4的Andr​​oid Wear,但未能在5.0.1(我使用Android的工作室并没有执行之前没有错误,成功打造,崩溃的模拟器。)

林当然知道,我用互联网permision就像你看到的:

 <使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =android.permission.ACCESS_WIFI_STATE/>
<使用特征的android:NAME =android.hardware.type.watch/>

格莱德说明:

 应用插件:'com.android.application

安卓{
    compileSdkVersion 21
    buildToolsVersion21.1.1

  defaultConfig {
    的applicationIDcom.hakyazilim.onlywear
    20的minSdkVersion
    targetSdkVersion 21
    版本code 1
    的versionName1.0
}
buildTypes {
    发布 {
        minifyEnabled假
        proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
    }
}

}

  {相关性
    编译文件树(导演:'库',包括:['的* .jar'])
    编译com.google.android.support:wearable:1.1.0
    编译com.google.android.gms:播放服务耐磨:87年6月5日
    编译文件(LIB / Android的异步HTTP-1.4.3.jar')
}

我用Android的异步HTTP-1.4.3.jar库。在此之后code:

 字符串requestURL =我的ASPX页面(包括XML);    asyncHttpClient.get(requestURL,新AsyncHtt presponseHandler(){
        @覆盖
        公共无效的onSuccess(字符串响应){
            尝试{
                mTextView.setText(response.toString());            }赶上(例外五){
                e.printStackTrace();
                Log.d(>>>>中,第1部分加载失败!);
            }
        }
        公共无效onFailure处(Throwable的E,串响应){
 //EROR =无法解析主机
        }
    });最好的祝福


解决方案

即使Android的5.1.1支持Wi-Fi功能。

它无法直接访问互联网Android Wear。

您应该坚持数据层API,你不能直接从表发送HTTP请求。从手机中获取互联网数据,然后转移其与数据层的API来观看。

您可以看到这个<一个href=\"http://stackoverflow.com/questions/31259692/does-android-wear-support-directly-access-the-internet\">Does Android Wear支持直接访问互联网?

和本文件的永远在线和Wi-Fi与最新的Andr​​oid Wear更新

I ve developed Android Wear App also SDK is 4.4AW. After finished that applitacion I tested on new android wear SDK that is 5.0.1 Emulator AND motorola360(with 5.0.1) then I recived this errror (Show in the below)

Message Sum:

can't resolve host

Detailed Message:

Unable to resolve host "URL": No address associated with hostname

The App works perfect on 4.4 android wear but failed on 5.0.1 (I used Android studio and there is no Error before execution , Successful Build, Crash on Emulator.)

Im certainly sure that I used internet permision as u can see :

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.type.watch" />

Glade Detail :

apply plugin: 'com.android.application'

android { compileSdkVersion 21 buildToolsVersion "21.1.1"

defaultConfig {
    applicationId "com.hakyazilim.onlywear"
    minSdkVersion 20
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.1.0'
    compile 'com.google.android.gms:play-services-wearable:6.5.87'
    compile files ('lib/android-async-http-1.4.3.jar')
}

I used "android-async-http-1.4.3.jar" Lib. Following this Code :

String requestURL = "My ASPX page (includes XML)";

    asyncHttpClient.get(requestURL, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(String response) {
            try {
                mTextView.setText(response.toString());

            } catch (Exception e) {
                e.printStackTrace();
                Log.d(">>>>", "Part 1 Load Fail !");
            }
        }
        public void onFailure(Throwable e, String response) {
 //"EROR = can't resolve host"
        }
    });

Best regards

解决方案

Even if Android 5.1.1 support Wi-Fi Feature.

It impossible to directly access the Internet in Android Wear.

You should stick to the Data Layer API , you cannot send http request directly from watch. Fetch internet data from the phone, then transfer it to watch with Data Layer API.

You can see this Does Android Wear support directly access the Internet?

And this document Always-on and Wi-Fi with the latest Android Wear update

这篇关于安卓5.0磨损无法解析主机(HTTP,AsyncClient ETC.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆