ionic cordova build android - error: package org.apache.http does not exist import org.apache.http.HttpResponse;
See original GitHub issueYour 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:
- Created 4 years ago
- Reactions:2
- Comments:11
Top GitHub Comments
Same problem here… Thanks for your answer, but it does not work for me
Edit your build.gradle file so that it looks like this: