Skip to main content

Crash on Android P - Didn't find class "org.apache.http.ProtocolVersion" #949

use this

If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the <application> element of AndroidManifest.xml.
<uses-library
       android:name="org.apache.http.legacy"
  android:required="false" />
If your app is targeting a lower API level, this is handled for you.
Curiously this doesn't happen on the master branch yet, so it must be a side effect of newer Maps API version in the nav branch, or a combination with other Firebase or Play Services features there.


The error message "Didn't find class "org.apache.http.ProtocolVersion"" is related to the use of the Apache HTTP library, which is no longer supported in Android P (API level 28) and higher. The class org.apache.http.ProtocolVersion is a part of this library.

To fix this issue, you will need to remove the dependency on the Apache HTTP library and replace it with a more recent library that is supported on Android P and higher. One popular alternative is the OkHttp library.

Here are the steps you can take to replace the Apache HTTP library with OkHttp:

  1. Remove the dependency on the Apache HTTP library from your app's build.gradle file.

  2. Add the OkHttp library to your app's build.gradle file. You can do this by adding the following line to the dependencies section:

implementation 'com.squareup.okhttp3:okhttp:4.x.x'
  1. Replace all instances of org.apache.http with okhttp3 in your app's code.

  2. Rebuild and test your app to ensure that the app no longer crashes and that all network-related functionality still works as expected.

  3. It's also important to keep in mind that other libraries you're using may be dependent on Apache HTTP classes, so you may need to update those libraries as well.

    It is also recommended to use HttpUrlConnection provided by android framework as it is more optimized for android and it is recommended by google.

Popular posts from this blog

How to setup wifi ADB debugger for android studio

How to setup wifi ADB debugger for android studio  Firstly set your adb path Which you can find here Step 1:  Goto your  Android sdk folder -> platform tools  and copy the whole path For example:  C:\Program Files (x86)\Android\android-sdk\platform-tools Step 2:  Goto command prompt or Android studio terminal cd C:\Program Files (x86)\Android\android-sdk\platform-tools and presss enter Step 3:  Connect your device & system with same wifi. Step 4:  Type  adb tcpip 5555  and press  Enter . Step 5:  Type  adb connect x.x.x.x:5555 , replacing the  x.x.x.x  with your phone IP address. find out phone IP address Settings -> About phone -> Status  (some phones may be vary) Note: Incase if you connect more than one devices disconnect other phones except which one you need to connect

how to create chat gpt app in android with java code

  I'd be happy to provide you with some sample Java code for a chat GPT app in Android, however it is important to note that creating a complete and functional app requires a solid understanding of Android development, Java and OpenAI API, and also the code I provide here is just a skeleton or a sample of what it would look like in practice. You would need to import the OpenAI API library and configure it with your API key. Here is an example of how you might use the OpenAI Java client library to send user input to the GPT-3 model and receive the generated response: import openai.OpenAI; public class ChatGPT { private OpenAI openai; private String apiKey = "YOUR_API_KEY"; public ChatGPT() { openai = new OpenAI(apiKey); } public String generateResponse(String input) { String response = ""; try { response = openai.completions().create() .engine("text-davinci-002") ...

How to create google map with drag marker to get user location with auto correct location edit text ...

For drag and drop with user location You have to create a google map fragment activity below are the xml code of google map xml <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".GetUserLocationActivity" > < fragment android :id ="@+id/mapuserloc" android :name ="com.google.android.gms.maps.SupportMapFragment" android :layout_width ="match_parent" android :layout_height ="522dp" app :layout_constraintEnd_toEndOf ="parent" app :layout_constraintStart_toStartOf ="p...