capacitor: “error: package android.support.v4.content does not exist”

Description of the problem: When trying to build the SDK with Android Studio on Mac I get: “error: package android.support.v4.content does not exist”

Affected platform

  • Android

OS of the development machine

  • macOS

Other information: The build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Capacitor version: 1.0.0

node version: v12.1.0 npm version: 6.9.0

CocoaPods version: It’s Android that’s giving issues

Steps to reproduce: Probably a bug in my system, so don’t know how to reproduce it somewhere else.

Link to sample project: Don’t have it

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 28 (4 by maintainers)

Most upvoted comments

Hi All,

Please install below plugin , it’s 100% working.

if Ionic 3/4 any.

ionic cordova plugin add cordova-plugin-androidx-adapter

Normal cordova

cordova plugin add cordova-plugin-androidx-adapter

SOLUTION TO error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider;

using jetify helped to solve .

from @ jcesarmobile’ s post — >https://github.com/ionic-team/capacitor/pull/2832

Error: “package android.support.* does not exist” This error occurs when some Cordova or Capacitor plugin has old android support dependencies instead of using the new AndroidX equivalent. You should report the issue in the plugin repository so the maintainers can update the plugin to use AndroidX dependencies.

As workaround you can also patch the plugin using jetifier

npm install jetifier npx jetify npx cap sync android

Looks like it’s related to some plugin using Android X.

Capacitor 2.0 will support Android X

https://github.com/ionic-team/capacitor/issues/1937

SOLUTION TO error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider;

using jetify helped to solve .

from @ jcesarmobile’ s post — >#2832

Error: “package android.support.* does not exist” This error occurs when some Cordova or Capacitor plugin has old android support dependencies instead of using the new AndroidX equivalent. You should report the issue in the plugin repository so the maintainers can update the plugin to use AndroidX dependencies.

As workaround you can also patch the plugin using jetifier

npm install jetifier npx jetify npx cap sync android

It works!! I just install cordova Camera with capacitor

SOLUTION TO error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider;

using jetify helped to solve .

from @ jcesarmobile’ s post — >#2832

Error: “package android.support.* does not exist” This error occurs when some Cordova or Capacitor plugin has old android support dependencies instead of using the new AndroidX equivalent. You should report the issue in the plugin repository so the maintainers can update the plugin to use AndroidX dependencies.

As workaround you can also patch the plugin using jetifier

npm install jetifier npx jetify npx cap sync android

thx dude

I’m seeing this too. I can confirm that the issue happens once you upgrade the android project.

The issue happens in the capacitor package, since it imports

import android.support.v4.content.LocalBroadcastManager;

in:

/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/background/BackgroundTaskService.java
/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/ui/ModalsBottomSheetDialogFragment.java
/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/background/BackgroundTask.java

In my case is Gradle 3.4.1 and Android Studio 3.4

I am also facing the exact same issue but with gradle 3.3.2 and capacitor 1.1.1 versions

Hi All,

Please install below plugin , it’s 100% working.

if Ionic 3/4 any.

ionic cordova plugin add cordova-plugin-androidx-adapter

Normal cordova

cordova plugin add cordova-plugin-androidx-adapter

Yes, this resolved my issue. Thanks you save my day

currently i’m facing a problem following version error:

implementation 'com.android.support:appcompat-v7:28.0.0' in android/app/build.gradle

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.1.1. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:27.1.1 when i install an Ionic Native plugin.

so when i open the file file capacitor-cordoba-android-plugins i see an error in the following line: implementation "com.android.support:support-v4:27.+" when i update it to the version: v7:28.0.0 seems like the problem is solved, but i don’t know if that is an error because of me or it’s a capacitor issue. please somebody help or give me and advice.

Same probleme with : classpath 'com.android.tools.build:gradle:3.3.2' gradle-4.10.1