NetworkSecurityConfig: No Network Security Config specified -- Android 7.0 error?
Asked Answered
R

3

10

I have some problem for android 7.0.0.

I use volley library for my application, and it works well except for Android 7.0

Here is part of my code;

String url_goster = "http://185.126.217.71/clog.php";
RequestQueue requestQueue;

StringRequest request= new StringRequest(Request.Method.POST, url_goster, new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {
        JSONObject veri_json;
        try {
            veri_json = new JSONObject(response);
            JSONArray serial_no = veri_json.getJSONArray("Bilgiler");

            for (int i = 0; i< serial_no.length(); i++){
                JSONObject bilgis = serial_no.getJSONObject(i);

                // JSON olarak verileri çekiyoruz
                String GELEN_SERIAL = bilgis.getString("GELEN_SERIAL");
                String TERMINAL_ADI = bilgis.getString("TERMINAL_ADI");
                String SICAKLIK_T1 = bilgis.getString("SICAKLIK_T1");
                String SICAKLIK_T2 = bilgis.getString("SICAKLIK_T2");
                String SICAKLIK_T3 = bilgis.getString("SICAKLIK_T3");
                String SON_DATA = bilgis.getString("SON_DATA");
                String NEM_H1 = bilgis.getString("NEM_H1");
                String NEM_H2 = bilgis.getString("NEM_H2");
                String NEM_H3 = bilgis.getString("NEM_H3");
                String SENSOR_1_AD = bilgis.getString("SENSOR_1_AD");
                String SENSOR_2_AD = bilgis.getString("SENSOR_2_AD");
                String SENSOR_3_AD = bilgis.getString("SENSOR_3_AD");
                int SENSOR_SAYISI = bilgis.getInt("SENSOR_SAYISI");

                kisiler.add(new Kisi(TERMINAL_ADI, SON_DATA, SENSOR_1_AD, SENSOR_2_AD, SENSOR_3_AD, SICAKLIK_T1, SICAKLIK_T2, SICAKLIK_T3, NEM_H1, NEM_H2, NEM_H3, GELEN_SERIAL, SENSOR_SAYISI));
            }
        } catch (JSONException e) {
            Log.e("JSON ALIRKEN HATA",e.getLocalizedMessage());

            Toast.makeText(getApplicationContext(), "Server'a bağlanılırken bir hata ile karşılaşıldı.", Toast.LENGTH_SHORT).show();
        }
    }
    }, new Response.ErrorListener() {
           @Override
           public void onErrorResponse(VolleyError error) {

           }
       }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> params = new HashMap<String,String>();
                params.put("ad",USER);
                return params;
            }
        };
        requestQueue.add(request);
    }

If I test my application on Android 7.0, the output of console is;

D/NetworkSecurityConfig: No Network Security Config specified, using platform default I/Choreographer: Skipped 127 frames! The application may be doing too much work on its main thread.

but this only happens Android 7.0 and application looks blank because it doesn't get a response from the internet

. How can i solve this problem ?

Regin answered 28/12, 2016 at 15:45 Comment(0)
U
13

There is no problem with this message:

D/NetworkSecurityConfig: No Network Security Config specified, using platform default 

The D/ indicates that this is a debugging message. It indicates that you do not have your own network security configuration defined, and so platform-default rules apply. This is perfectly fine.

application looks empty because it does not response from the internet

Near as I can tell, you are parsing some JSON, iterating over it, and populating kisiler. Perhaps kisiler is not connected to your UI.

Unfolded answered 28/12, 2016 at 15:49 Comment(2)
Thank you for answer. But all other versions are working, only Android 7.0 not working and i dont know why :(Regin
@Stephen: "I see even-though we used internet permission, it is not connected to the internet" -- until somebody publishes a complete working example of something that demonstrates a problem, neither I nor Google nor anyone else can help. I have had no issues with Internet access on Android 7.0+, and I do not see any issues files referring to that LogCat label.Unfolded
H
1

So, I don't think the previous answer was clear enough. (I spent a couple of hours trying to "debug" this)

If you're seeing this prompt, the fact that it says

D/ blablabla

means that this is a Debug, and not an error. It's more like a notification to let you know that you didn't specify the NetworkSecurityConfig, and that it decided by itself to set it to default. Nothing wrong.

Your error, however, will show itself as:

E/ blebleble

TL;DR You might be looking at the wrong place if you're trying to debug an error.

Hwu answered 25/11, 2017 at 4:11 Comment(0)
T
1

try adding this to the manifest.xml

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

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

and change the android emulator to pixel 2 API 28 from the AVD manager it worked for me in both windows and mac

Thoracoplasty answered 27/12, 2019 at 0:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.