无法解析Android应用程序的主机,为什么?

问题描述

我已经开发了一个带有MysqL后端的android原生应用。当互联网连接正常时,我遇到一个问题,当我尝试登录该应用程序时,出现了一个错误消息,提示为“ Volley connection Error:无法在上述API中的电话中解析我的托管服务器的主机27版本,但在没有提到27 API版本android手机的情况下也可以使用。 为什么我遇到这个问题?

Error msg

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsversion "30.0.0"

    defaultConfig {
        applicationId "com.example.MysqL"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        useLibrary 'org.apache.http.legacy'

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation filetree(dir: "libs",include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.cardview:cardview:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'

    //noinspection GradleCompatible
    implementation'com.android.support:design:28.0.0'
    implementation'com.android.volley:volley:1.1.1'
    implementation'com.rengwuxian.materialedittext:library:2.1.4'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
  //  compile 'com.github.bumptech.glide:glide:4.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.picasso:picasso:2.71828'

    compile('com.github.bumptech.glide:glide:4.4.0@aar') {
        transitive = true;
    }

  


}

解决方法

将此代码添加到android清单文件的应用程序标签中。

<application
    android:usesCleartextTraffic="true" 
    >

</application>