question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ionic cordova build android - error: package org.apache.http does not exist import org.apache.http.HttpResponse;

See original GitHub issue

Your Environment

  • Plugin version: ^3.1.0
  • Platform: iOS or Android
  • OS version: Windows 10 Home (1903)
  • Device manufacturer and model: Samsung Galaxy S10+
  • Running in Simulator: No
  • Cordova version (cordova -v): 9.0.0 (cordova-lib@9.0.1)
  • Cordova platform version (cordova platform ls): Installed platforms: android 8.1.0 Available platforms: browser ^6.0.0 electron ^1.0.0 ios ^5.0.0 osx ^5.0.0 windows ^7.0.0
  • Plugin configuration options: “cordova”: { “plugins”: { “cordova-plugin-whitelist”: {}, “cordova-plugin-statusbar”: {}, “cordova-plugin-device”: {}, “cordova-plugin-splashscreen”: {}, “cordova-plugin-ionic-webview”: { “ANDROID_SUPPORT_ANNOTATIONS_VERSION”: “27.+” }, “cordova-plugin-ionic-keyboard”: {}, “cordova-plugin-geolocation”: { “GEOLOCATION_USAGE_DESCRIPTION”: “To log kms travel” }, “cordova-plugin-advanced-http”: {}, “cordova-plugin-background-geolocation”: { “GOOGLE_PLAY_SERVICES_VERSION”: “11+”, “ANDROID_SUPPORT_LIBRARY_VERSION”: “26+”, “ICON”: “@mipmap/icon”, “SMALL_ICON”: “@mipmap/icon”, “ACCOUNT_NAME”: “@string/app_name”, “ACCOUNT_LABEL”: “@string/app_name”, “ACCOUNT_TYPE”: “$PACKAGE_NAME.account”, “CONTENT_AUTHORITY”: “$PACKAGE_NAME” }, “cordova-android-support-gradle-release”: { “ANDROID_SUPPORT_VERSION”: “27.+” } },
  • Link to your project:

Context

running ionic cordova build android

Expected Behavior

Successful build

Actual Behavior

C:\Work\kms-app\platforms\android\gradlew: Command failed with exit code 1 Error output: C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:6: error: package org.apache.http does not exist import org.apache.http.HttpResponse; ^ C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:7: error: package org.apache.http.client.methods does not exist import org.apache.http.client.methods.HttpPost; ^ C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:8: error: package org.apache.http.entity does not exist import org.apache.http.entity.StringEntity; ^ C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:9: error: package org.apache.http.impl.client does not exist import org.apache.http.impl.client.DefaultHttpClient; ^ C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:662: error: cannot find symbol DefaultHttpClient httpClient = new DefaultHttpClient(); ^ symbol: class DefaultHttpClient location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:662: error: cannot find symbol DefaultHttpClient httpClient = new DefaultHttpClient(); ^ symbol: class DefaultHttpClient location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:663: error: cannot find symbol HttpPost request = new HttpPost(url); ^ symbol: class HttpPost location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:663: error: cannot find symbol HttpPost request = new HttpPost(url); ^ symbol: class HttpPost location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:677: error: cannot find symbol StringEntity se = new StringEntity(params.toString()); ^ symbol: class StringEntity location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:677: error: cannot find symbol StringEntity se = new StringEntity(params.toString()); ^ symbol: class StringEntity location: class LocationUpdateService C:\Work\kms-app\platforms\android\app\src\main\java\com\zencity\cordova\bgloc\LocationUpdateService.java:691: error: cannot find symbol HttpResponse response = httpClient.execute(request); ^ symbol: class HttpResponse location: class LocationUpdateService Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Work\kms-app\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 11 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Possible Fix

Steps to Reproduce

Context

Debug logs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

1reaction
json-alzatecommented, Mar 3, 2020

Edit your build.gradle file so that it looks like this:

...

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

    ...
}

...

Same problem here… Thanks for your answer, but it does not work for me

1reaction
dioslibrecommented, Feb 12, 2020

Edit your build.gradle file so that it looks like this:

...

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

    ...
}

...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Package org.apache.http does not exist and the app dont ...
Hi! Im learning ionic but I have a problem, I have been trying to solve this, but I dont know how. When I...
Read more >
package org.apache.http.client does not exist - Stack Overflow
From this answer here: stackoverflow.com/questions/50461881/… You also need to add ' android:usesCleartextTraffic="true" ' and ' <uses-library ...
Read more >
How to solve package org.apache.http does not exist
Just download the Apache HttpComponents , and select the appropriate version . For example the HttpClient 5.0.3 version , or the HttpClient 4.5....
Read more >
How to solve package org.apache.http does not exist
Just download the Apache HttpComponents , and select the appropriate version . For example the HttpClient ... error: package org.apache.http does not exist....
Read more >
Blog - Apache Cordova
Apache Cordova apps built for Android devices which allow the loading of http content from domains they do not control could be affected....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found