Получение java.net.UnknownHostException: в модификации - PullRequest
0 голосов
/ 25 июня 2018

Когда я пытаюсь получить доступ к URL с помощью метода получения,

D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "xyz.aaa.net": No address associated with hostname 

Но я получаю ответ об успехе в POST MAN. Прошло два дня, но я ничего не понял. Изменил фактический URL на xyz.aaa.net из-за проблемы авторизации. Извините за это:

Call<Response> call2 = apiInterface.getEmployeeListNew("1190",1008,"true"
                );
        call2.enqueue(new Callback<Response>() {
            @Override
            public void onResponse(Call<TaxProResponse> call, Response<Response> response) { }

            @Override
            public void onFailure(Call<TaxProResponse> call, Throwable t) {
                call.cancel();
            }
        });

API-клиент:

class APIClient {

    private static Retrofit retrofit = null;

    static Retrofit getClient() {

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();


        retrofit = new Retrofit.Builder()
                .baseUrl("http://xyz.aaa.net/api/")
                .addConverterFactory(GsonConverterFactory.create())
                .client(client)
                .build();



        return retrofit;
    }

}

APIInterface:

@GET("Profile")
Call<Response> getEmployeeListNew(
        @Header("app_id") String app_id,
        @Query("office_id") int office_id,
        @Query("need_only_active") String need_only_active
);

весь URL должен быть таким с app_id в качестве заголовка:

http://xyz.aaa.net/api/Profile?office_id=1008&need_only_active=true

Если кто-то из вас сталкивался с этой проблемой, пожалуйста, предложите немного. Пробовал с каким-то другим запросом, все работает нормально. Предоставьте разрешение,

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

Это не вопрос разрешения, как другие вопросы в Stackoverflow. Пробовал с там решениями и он не работает.

На вопрос, полный журнал

06-25 12:11:38.143 8450-8450/? I/zygote64: Late-enabling -Xcheck:jni
06-25 12:11:38.436 8450-8450/com.journaldev.retrofitintro D/NetworkSecurityConfig: No Network Security Config specified, using platform default
06-25 12:11:38.495 8450-8469/com.journaldev.retrofitintro D/OkHttp: --> GET http://xyz.aaa.net/api/AMTPProfile?office_id=1008&need_only_active=true http/1.1
    app_id: 1190
06-25 12:11:38.497 8450-8469/com.journaldev.retrofitintro D/OkHttp: --> END GET
06-25 12:11:38.516 8450-8471/com.journaldev.retrofitintro D/OpenGLRenderer: HWUI GL Pipeline
06-25 12:11:38.561 8450-8471/com.journaldev.retrofitintro I/Adreno: QUALCOMM build                   : 8e59954, I0be83d0d26
    Build Date                       : 09/22/17
    OpenGL ES Shader Compiler Version: EV031.21.02.00
    Local Branch                     : O17A
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
06-25 12:11:38.564 8450-8471/com.journaldev.retrofitintro D/vndksupport: Loading /vendor/lib64/hw/gralloc.msm8994.so from current namespace instead of sphal namespace.
06-25 12:11:38.581 8450-8471/com.journaldev.retrofitintro I/Adreno: PFP: 0x00000000, ME: 0x00000000
06-25 12:11:38.598 8450-8471/com.journaldev.retrofitintro I/zygote64: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
06-25 12:11:38.602 8450-8471/com.journaldev.retrofitintro I/OpenGLRenderer: Initialized EGL, version 1.4
06-25 12:11:38.603 8450-8471/com.journaldev.retrofitintro D/OpenGLRenderer: Swap behavior 2
06-25 12:11:38.622 8450-8471/com.journaldev.retrofitintro D/vndksupport: Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
    Loading /vendor/lib64/hw/gralloc.msm8994.so from current namespace instead of sphal namespace.
06-25 12:11:41.808 8450-8469/com.journaldev.retrofitintro D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "xyz.aaa.net": No address associated with hostname

Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...