Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with android.support.v4.content #539

Closed
3 tasks done
florianmonfort opened this issue Dec 13, 2019 · 10 comments
Closed
3 tasks done

Build fails with android.support.v4.content #539

florianmonfort opened this issue Dec 13, 2019 · 10 comments

Comments

@florianmonfort
Copy link

florianmonfort commented Dec 13, 2019

Bug Report

Problem

What is expected to happen?

Android should build successfully

What does actually happen?

Build fails.

Information

Hi,

I have a project that was running without AndroidX before so it could be compiled, but now to target higher API levels we need to use androidx. So to solve this issue we have installed the following plugins:

cordova-plugin-androidx
cordova-plugin-androidx-adapter

However during build time we still get the following error, including from camera cordova plugin:

`

Task :app:processDebugResources

Task :app:compileDebugJavaWithJavac FAILED
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:64: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/org/apache/cordova/camera/CordovaUri.java:25: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/org/apache/cordova/camera/FileProvider.java:21: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {}
^
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
^
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:114: error: cannot find symbol
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
^
symbol: class RequiresApi
location: class IonicWebViewEngine.ServerClient
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:297: error: cannot find symbol
this.imageUri = new CordovaUri(FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
/Users/dev/Developer/diningcity-assistant/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:803: error: cannot find symbol
Uri tmpFile = FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors
FAILURE: Build failed with an exception.
`

So it seems both this plugin cordova-plugin-ionic-webview and camera are involved.

Command or Code

cordova build android

Environment, Platform, Device

MacOS, Mojave

Version information

ionic info

Ionic:

   Ionic CLI                     : 5.4.12 (/Users/dev/.nvm/versions/node/v12.1.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.0-dev.201904251558.2457a23
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.2.3
   @angular/cli                  : 7.2.3
   @ionic/angular-toolkit        : 1.2.3

Capacitor:

   Capacitor CLI   : 1.0.0-beta.22
   @capacitor/core : 1.0.0-beta.19

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.3, (and 18 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   ios-deploy : 1.9.4
   ios-sim    : 8.0.1
   NodeJS     : v12.1.0 (/Users/dev/.nvm/versions/node/v12.1.0/bin/node)
   npm        : 6.9.0
   OS         : macOS Catalina
   Xcode      : Xcode 11.2.1 Build version 11B500
`
Cordova plugins list:

cordova plugin list
call-number 0.0.2 "Cordova Call Number Plugin"
cordova-android-support-gradle-release 3.0.0 "cordova-android-support-gradle-release"
cordova-clipboard 1.2.1 "Clipboard"
cordova-plugin-android-permissions 1.0.0 "Permissions"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-crop 0.3.1 "CropPlugin"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 5.0.0 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-image-picker 1.1.1 "ImagePicker"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
cordova-plugin-jcore 1.2.8 "JCore"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 3.2.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
jpush-phonegap-plugin 3.6.4 "JPush"

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@pbergner
Copy link

any updates?

@florianmonfort
Copy link
Author

any updates?

Not on my side, only choice I had left was to revert back to using Cordova Android 7.1.4, cannot use Cordova Android 8.x

@timbru31
Copy link
Member

timbru31 commented Apr 2, 2020

Closing as a duplicate of #405 - potential PR is at #418

@timbru31 timbru31 closed this as completed Apr 2, 2020
@rodrigoords
Copy link

All tasks that talk about this problem were closed but the problem persists.
Cordova team closed the PR #418 without solution and ionic team closed the ionic-team/cordova-plugin-ionic-webview#275 with the comment that the problem won't occur anymore.
What we need to do to use this plugin ?

@timbru31
Copy link
Member

The PR #418 is not closed. cordova-android@9 added opt-in AndroidX support.

The general discussion about enforcing AndroidX in our core plugins is at apache/cordova#69

@rodrigoords
Copy link

To make this work correctly with ionic I did:
Migrate cordova to version 9 https://cordova.apache.org/announcements/2020/06/29/cordova-android-9.0.0.html
Add cordova-plugin-androidx-adapter
And adjust config file with

@dogofpavlov
Copy link

To make this work correctly with ionic I did:
Migrate cordova to version 9 https://cordova.apache.org/announcements/2020/06/29/cordova-android-9.0.0.html
Add cordova-plugin-androidx-adapter
And adjust config file with

Hey dude... you left off the last bit of your sentence... adjust config file with what? I'm having the same problem.

@signalpoint
Copy link

signalpoint commented Dec 14, 2020

The following fixed it for me:

cordova plugin add cordova-plugin-androidx
cordova plugin add cordova-plugin-androidx-adapter
cordova plugin save
cordova clean android
cordova build android

I am not using Ionic.

@Kunj-Choksi
Copy link

cordova plugin add cordova-plugin-androidx-adapter

This solved my issue.
Thanks

@karlhaak
Copy link

I had added cordova-plugin-androidx-adapter before adding the camera plugin.
removing cordova-plugin-androidx-adapter and adding it again solved my problem.
Order of adding plugins matters here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants