Android country list in xml

<string-array name="array_countries">
    <item>Ascension Island</item>
    <item>Andorra</item>
    <item>United Arab Emirates</item>
    <item>Afghanistan</item>
    <item>Antigua &amp; Barbuda</item>
    <item>Anguilla</item>
    <item>Albania</item>
    <item>Armenia</item>
    <item>Angola</item>
    <item>Antarctica</item>
    <item>Argentina</item>
    <item>American Samoa</item>
    <item>Austria</item>
    <item>Australia</item>
    <item>Aruba</item>
    <item>Åland Islands</item>
    <item>Azerbaijan</item>
    <item>Bosnia &amp; Herzegovina</item>
    <item>Barbados</item>
    <item>Bangladesh</item>
    <item>Belgium</item>
    <item>Burkina Faso</item>
    <item>Bulgaria</item>
    <item>Bahrain</item>
    <item>Burundi</item>
    <item>Benin</item>
    <item>St. Barthélemy</item>
    <item>Bermuda</item>
    <item>Brunei</item>
    <item>Bolivia</item>
    <item>Caribbean Netherlands</item>
    <item>Brazil</item>
    <item>Bahamas</item>
    <item>Bhutan</item>
    <item>Bouvet Island</item>
    <item>Botswana</item>
    <item>Belarus</item>
    <item>Belize</item>
    <item>Canada</item>
    <item>Cocos (Keeling) Islands</item>
    <item>Congo - Kinshasa</item>
    <item>Central African Republic</item>
    <item>Congo - Brazzaville</item>
    <item>Switzerland</item>
    <item>Côte d’Ivoire</item>
    <item>Cook Islands</item>
    <item>Chile</item>
    <item>Cameroon</item>
    <item>China mainland</item>
    <item>Colombia</item>
    <item>Clipperton Island</item>
    <item>Costa Rica</item>
    <item>Cuba</item>
    <item>Cape Verde</item>
    <item>Curaçao</item>
    <item>Christmas Island</item>
    <item>Cyprus</item>
    <item>Czechia</item>
    <item>Germany</item>
    <item>Diego Garcia</item>
    <item>Djibouti</item>
    <item>Denmark</item>
    <item>Dominica</item>
    <item>Dominican Republic</item>
    <item>Algeria</item>
    <item>Ceuta &amp; Melilla</item>
    <item>Ecuador</item>
    <item>Estonia</item>
    <item>Egypt</item>
    <item>Western Sahara</item>
    <item>Eritrea</item>
    <item>Spain</item>
    <item>Ethiopia</item>
    <item>Finland</item>
    <item>Fiji</item>
    <item>Falkland Islands</item>
    <item>Micronesia</item>
    <item>Faroe Islands</item>
    <item>France</item>
    <item>Gabon</item>
    <item>United Kingdom</item>
    <item>Grenada</item>
    <item>Georgia</item>
    <item>French Guiana</item>
    <item>Guernsey</item>
    <item>Ghana</item>
    <item>Gibraltar</item>
    <item>Greenland</item>
    <item>Gambia</item>
    <item>Guinea</item>
    <item>Guadeloupe</item>
    <item>Equatorial Guinea</item>
    <item>Greece</item>
    <item>So. Georgia &amp; So. Sandwich Isl.</item>
    <item>Guatemala</item>
    <item>Guam</item>
    <item>Guinea-Bissau</item>
    <item>Guyana</item>
    <item>Hong Kong</item>
    <item>Heard &amp; McDonald Islands</item>
    <item>Honduras</item>
    <item>Croatia</item>
    <item>Haiti</item>
    <item>Hungary</item>
    <item>Canary Islands</item>
    <item>Indonesia</item>
    <item>Ireland</item>
    <item>Israel</item>
    <item>Isle of Man</item>
    <item>India</item>
    <item>British Indian Ocean Territory</item>
    <item>Iraq</item>
    <item>Iran</item>
    <item>Iceland</item>
    <item>Italy</item>
    <item>Jersey</item>
    <item>Jamaica</item>
    <item>Jordan</item>
    <item>Japan</item>
    <item>Kenya</item>
    <item>Kyrgyzstan</item>
    <item>Cambodia</item>
    <item>Kiribati</item>
    <item>Comoros</item>
    <item>St. Kitts &amp; Nevis</item>
    <item>North Korea</item>
    <item>South Korea</item>
    <item>Kuwait</item>
    <item>Cayman Islands</item>
    <item>Kazakhstan</item>
    <item>Laos</item>
    <item>Lebanon</item>
    <item>St. Lucia</item>
    <item>Liechtenstein</item>
    <item>Sri Lanka</item>
    <item>Liberia</item>
    <item>Lesotho</item>
    <item>Lithuania</item>
    <item>Luxembourg</item>
    <item>Latvia</item>
    <item>Libya</item>
    <item>Morocco</item>
    <item>Monaco</item>
    <item>Moldova</item>
    <item>Montenegro</item>
    <item>St. Martin</item>
    <item>Madagascar</item>
    <item>Marshall Islands</item>
    <item>North Macedonia</item>
    <item>Mali</item>
    <item>Myanmar (Burma)</item>
    <item>Mongolia</item>
    <item>Macao</item>
    <item>Northern Mariana Islands</item>
    <item>Martinique</item>
    <item>Mauritania</item>
    <item>Montserrat</item>
    <item>Malta</item>
    <item>Mauritius</item>
    <item>Maldives</item>
    <item>Malawi</item>
    <item>Mexico</item>
    <item>Malaysia</item>
    <item>Mozambique</item>
    <item>Namibia</item>
    <item>New Caledonia</item>
    <item>Niger</item>
    <item>Norfolk Island</item>
    <item>Nigeria</item>
    <item>Nicaragua</item>
    <item>Netherlands</item>
    <item>Norway</item>
    <item>Nepal</item>
    <item>Nauru</item>
    <item>Niue</item>
    <item>New Zealand</item>
    <item>Oman</item>
    <item>Panama</item>
    <item>Peru</item>
    <item>French Polynesia</item>
    <item>Papua New Guinea</item>
    <item>Philippines</item>
    <item>Pakistan</item>
    <item>Poland</item>
    <item>St. Pierre &amp; Miquelon</item>
    <item>Pitcairn Islands</item>
    <item>Puerto Rico</item>
    <item>Palestinian Territories</item>
    <item>Portugal</item>
    <item>Palau</item>
    <item>Paraguay</item>
    <item>Qatar</item>
    <item>Réunion</item>
    <item>Romania</item>
    <item>Serbia</item>
    <item>Russia</item>
    <item>Rwanda</item>
    <item>Saudi Arabia</item>
    <item>Solomon Islands</item>
    <item>Seychelles</item>
    <item>Sudan</item>
    <item>Sweden</item>
    <item>Singapore</item>
    <item>St. Helena</item>
    <item>Slovenia</item>
    <item>Svalbard &amp; Jan Mayen</item>
    <item>Slovakia</item>
    <item>Sierra Leone</item>
    <item>San Marino</item>
    <item>Senegal</item>
    <item>Somalia</item>
    <item>Suriname</item>
    <item>South Sudan</item>
    <item>São Tomé &amp; Príncipe</item>
    <item>El Salvador</item>
    <item>Sint Maarten</item>
    <item>Syria</item>
    <item>Eswatini</item>
    <item>Tristan da Cunha</item>
    <item>Turks &amp; Caicos Islands</item>
    <item>Chad</item>
    <item>French Southern Territories</item>
    <item>Togo</item>
    <item>Thailand</item>
    <item>Tajikistan</item>
    <item>Tokelau</item>
    <item>Timor-Leste</item>
    <item>Turkmenistan</item>
    <item>Tunisia</item>
    <item>Tonga</item>
    <item>Turkey</item>
    <item>Trinidad &amp; Tobago</item>
    <item>Tuvalu</item>
    <item>Taiwan</item>
    <item>Tanzania</item>
    <item>Ukraine</item>
    <item>Uganda</item>
    <item>U.S. Outlying Islands</item>
    <item>United States</item>
    <item>Uruguay</item>
    <item>Uzbekistan</item>
    <item>Vatican City</item>
    <item>St. Vincent &amp; Grenadines</item>
    <item>Venezuela</item>
    <item>British Virgin Islands</item>
    <item>U.S. Virgin Islands</item>
    <item>Vietnam</item>
    <item>Vanuatu</item>
    <item>Wallis &amp; Futuna</item>
    <item>Samoa</item>
    <item>Kosovo</item>
    <item>Yemen</item>
    <item>Mayotte</item>
    <item>South Africa</item>
    <item>Zambia</item>
    <item>Zimbabwe</item>
</string-array>

The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY

This could happen if you have two entries like in your AndroidManifest.xml. If you choose File -> New -> Activity -> Blank Activity this gets included in manifest file automatically. If you are not building for wearable you can delete this from manifest file or add missing library in build.gradle (app)

<uses-library
    android:name="com.google.android.wearable"
    android:required="true" />
<!--
       Set to true if your app is Standalone, that is, it does not require the handheld
       app to run.
-->
<meta-data
    android:name="com.google.android.wearable.standalone"
    android:value="true" />

Volley json post request android

Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. Volley is available on GitHub.

Find your build.gradle (app) add this under dependencies

implementation 'com.android.volley:volley:1.2.0'

Create a singleton class to manage all requests

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class AppHttp {
    private static AppHttp instance;
    private RequestQueue requestQueue;
    private static Context ctx;

    private AppHttp(Context context) {
        ctx = context;
        requestQueue = getRequestQueue();
    }

    public static synchronized AppHttp getInstance(Context context) {
        if (instance == null) {
            instance = new AppHttp(context);
        }
        return instance;
    }

    public RequestQueue getRequestQueue() {
        if (requestQueue == null) {
            // getApplicationContext() is key, it keeps you from leaking the
            // Activity or BroadcastReceiver if someone passes one in.
            requestQueue = Volley.newRequestQueue(ctx.getApplicationContext());
        }
        return requestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req) {
        getRequestQueue().add(req);
    }
}

Create your POST request

AppHttp requestQueue = AppHttp.getInstance(this);
JSONObject postData = new JSONObject();
    try {
        postData.put("email", email);
        postData.put("password", password);

    } catch (JSONException e) {
        e.printStackTrace();
    }

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, "http://api.com/login", postData, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            Log.e("login response: ", response.toString());
            try {
                // Retrieve user information and take user to next activity
               // after successful login
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    },
        new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("login error: ", error.toString());
                error.printStackTrace();

                // show user login error with a Toast
            }
        }
    ) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("Accept", "application/json;charset=utf-8");
            params.put("Content-Type", "application/json;charset=utf-8");

            return params;
        }
    };

    requestQueue.addToRequestQueue(jsonObjectRequest);
}