0

I am building an Android application for uploading images and videos to a server. Everything looks fine, but when i try to run or debug the app i get this error.

Error:(15, 8) error: cannot access HttpEntity class file for org.apache.http.HttpEntity not found.

I have googled and tried many solutions including this How do I properly import HttpClient from org.apache on Android using gradle build file?

I have extended the Apache HttpMultipartEntity class to create my custom MultiPartEntity class. I have also included the httpmime-4.2.6.jar file as a library.Can someone help me out.

Community
  • 1
  • 1

1 Answers1

0

See in your build.gradle file whether the minSdkVersion is 23 and if yes, declare the following compile-time dependency in the android section of your build.gradle

useLibrary 'org.apache.http.legacy'

ie, the android section in your build.gradle file would be like,

android {
    useLibrary 'org.apache.http.legacy'
}

along with other entries.

From the docs, the Apache libraries were deprecated and removed from the Android SDK in Android MarshMallow.

Lal
  • 14,726
  • 4
  • 45
  • 70