Note for Android 9 (Pie).
Additionally to useLibrary 'org.apache.http.legacy'
you have to add in AndroidManifest.xml:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Source: https://developer.android.com/about/versions/pie/android-9.0-changes-28