Manifest merger failed on android

Hi, I’ve just upgraded my @capacitor/core, @capacitor/android, and @capacitor/ios to “2.0.2” and the problem starts to emerge. My application is building fine before these upgrades that I made. Here’s the full error message that I get from Android Studio:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
  	is also present at [androidx.core:core:1.2.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
  	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-44:19 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s
34 actionable tasks: 3 executed, 31 up-to-date

I even get a suggestion from the Android Studio but unfortunately, it still won’t build. This is what it suggests:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
	is also present at [androidx.core:core:1.2.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-44:19 to override.

And here’s my full package.json file:

{
  "name": "THIS IS MY APPLICATION NAME",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@capacitor/android": "^2.0.2",
    "@capacitor/core": "2.0.2",
    "@capacitor/ios": "^2.0.2",
    "@ionic-native/core": "^5.19.0",
    "@ionic-native/http": "^5.19.0",
    "@ionic-native/image-picker": "^5.19.1",
    "@ionic-native/in-app-browser": "^5.19.0",
    "@ionic-native/in-app-purchase": "^5.23.0",
    "@ionic-native/screen-orientation": "^5.20.0",
    "@ionic/react": "^4.11.10",
    "@ionic/react-router": "^4.11.7",
    "@types/jest": "^24.0.18",
    "@types/node": "^12.7.12",
    "@types/react": "^16.9.5",
    "@types/react-dom": "^16.9.1",
    "@types/react-router": "^5.1.1",
    "@types/react-router-dom": "^5.1.0",
    "chart.js": "^2.9.3",
    "cordova-plugin-advanced-http": "^2.3.1",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-inappbrowser": "^3.1.0",
    "cordova-plugin-inapppurchase": "^1.2.0",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-telerik-imagepicker": "^2.3.3",
    "es6-promise-plugin": "^4.2.2",
    "ionic-native": "^2.9.0",
    "react": "^16.10.2",
    "react-chartjs-2": "^2.8.0",
    "react-click-n-hold": "^1.0.7",
    "react-dom": "^16.10.2",
    "react-router": "^5.1.0",
    "react-router-dom": "^5.1.0",
    "react-shimmer": "^2.0.1",
    "react-zoom-pan-pinch": "^1.6.1",
    "typescript": "3.6.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "description": "An Ionic project",
  "devDependencies": {
    "@capacitor/cli": "1.3.0",
    "react-scripts": "^3.4.0"
  }
}

I decided to upgrade my capacitor as I was not able to use capacitor’s push notification plugin (the function requestPermission() is undefined). I searched up the forum and found out that the docs are for capacitor 2.0.0 up. I’m currently stuck and can’t find any working solutions throughout the forums, so hopefully someone knows something that could help. Thanks.

Edit: Oh, I forgot to say that I’m using React instead of Angular. Thanks again

Check this, the error is not the same, but the problem is
https://capacitor.ionicframework.com/docs/android/troubleshooting#error-package-android-support-does-not-exist

Thanks @jcesarmobile, I’ve tried running npx cap copy android just like the docs says, but apparently it still won’t build. I assume that it’s a problem in migrating to androidx as the project seems to be using both androidx and the support version and I couldn’t find a solution to prevent this from happening. I may not be right, but it’s just what I think according to the error messages

No, I linked the previous section, but the title gets hidden by the header

Yo have to

npm install jetifier
npx jetify
npx cap sync android

1 Like

Sorry @jcesarmobile, I got the wrong idea. I’ve tried installing jetifier using yarn add jetifier and run both npx jetify and npx cap sync android. I think original problem is solved as there is no longer any error about androidx. However, I am getting a long error:

Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavac FAILED
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\ImagePicker.java:23: error: package androidx.core.app does not exist
import androidx.core.app.ActivityCompat;
                        ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\ImagePicker.java:24: error: package androidx.core.content does not exist
import androidx.core.content.ContextCompat;
                            ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:65: error: package androidx.appcompat.app does not exist
import androidx.appcompat.app.ActionBar;
                             ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:66: error: package androidx.appcompat.app does not exist
import androidx.appcompat.app.AppCompatActivity;
                             ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:81: error: cannot find symbol
public class MultiImageChooserActivity extends AppCompatActivity implements
                                               ^
  symbol: class AppCompatActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\ImagePicker.java:108: error: cannot find symbol
            PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
                                                 ^
  symbol:   variable ContextCompat
  location: class ImagePicker
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\ImagePicker.java:114: error: cannot find symbol
            ActivityCompat.requestPermissions(
            ^
  symbol:   variable ActivityCompat
  location: class ImagePicker
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:126: error: method does not override or implement a method from a supertype
    @Override
    ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:128: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:129: error: no suitable constructor found for FakeR(MultiImageChooserActivity)
        fakeR = new FakeR(this);
                ^
    constructor FakeR.FakeR(Activity) is not applicable
      (argument mismatch; MultiImageChooserActivity cannot be converted to Activity)
    constructor FakeR.FakeR(Context) is not applicable
      (argument mismatch; MultiImageChooserActivity cannot be converted to Context)
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:130: error: cannot find symbol
        setContentView(fakeR.getId("layout", "multiselectorgrid"));
        ^
  symbol:   method setContentView(int)
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:133: error: cannot find symbol
        maxImages = getIntent().getIntExtra(MAX_IMAGES_KEY, NOLIMIT);
                    ^
  symbol:   method getIntent()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:134: error: cannot find symbol
        desiredWidth = getIntent().getIntExtra(WIDTH_KEY, 0);
                       ^
  symbol:   method getIntent()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:135: error: cannot find symbol
        desiredHeight = getIntent().getIntExtra(HEIGHT_KEY, 0);
                        ^
  symbol:   method getIntent()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:136: error: cannot find symbol
        quality = getIntent().getIntExtra(QUALITY_KEY, 0);
                  ^
  symbol:   method getIntent()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:138: error: cannot find symbol
        outputType = OutputType.fromValue(getIntent().getIntExtra(OUTPUT_TYPE_KEY, 0));
                                          ^
  symbol:   method getIntent()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:140: error: cannot find symbol
        Display display = getWindowManager().getDefaultDisplay();
                          ^
  symbol:   method getWindowManager()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:145: error: cannot find symbol
        GridView gridView = (GridView) findViewById(fakeR.getId("id", "gridview"));
                                       ^
  symbol:   method findViewById(int)
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:177: error: cannot find symbol
        getLoaderManager().initLoader(CURSORLOADER_THUMBS, null, this);
        ^
  symbol:   method getLoaderManager()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:178: error: cannot find symbol
        getLoaderManager().initLoader(CURSORLOADER_REAL, null, this);
        ^
  symbol:   method getLoaderManager()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:181: error: incompatible types: MultiImageChooserActivity cannot be converted to Context
        progress = new ProgressDialog(this);
                                      ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:182: error: cannot find symbol
        progress.setTitle(getString(fakeR.getId("string", "multi_image_picker_processing_images_title")));
                          ^
  symbol:   method getString(int)
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:183: error: cannot find symbol
        progress.setMessage(getString(fakeR.getId("string", "multi_image_picker_processing_images_message")));
                            ^
  symbol:   method getString(int)
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:199: error: incompatible types: MultiImageChooserActivity cannot be converted to Context
            new AlertDialog.Builder(this)
                                    ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:262: error: incompatible types: MultiImageChooserActivity cannot be converted to Context
                this,
                ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:308: error: cannot find symbol
        setResult(RESULT_CANCELED);
                  ^
  symbol:   variable RESULT_CANCELED
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:309: error: cannot find symbol
        finish();
        ^
  symbol:   method finish()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:318: error: cannot find symbol
            setResult(RESULT_CANCELED);
                      ^
  symbol:   variable RESULT_CANCELED
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:320: error: cannot find symbol
            finish();
            ^
  symbol:   method finish()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:322: error: cannot find symbol
            setRequestedOrientation(getResources().getConfiguration().orientation); //prevent orientation changes during processing
                                    ^
  symbol:   method getResources()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:356: error: cannot find symbol
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
                                                                    ^
  symbol:   variable LAYOUT_INFLATER_SERVICE
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:380: error: cannot find symbol
        ActionBar actionBar = getSupportActionBar();
        ^
  symbol:   class ActionBar
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:380: error: cannot find symbol
        ActionBar actionBar = getSupportActionBar();
                              ^
  symbol:   method getSupportActionBar()
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:383: error: cannot find symbol
                    ActionBar.DISPLAY_SHOW_CUSTOM,
                    ^
  symbol:   variable ActionBar
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:384: error: cannot find symbol
                    ActionBar.DISPLAY_SHOW_CUSTOM
                    ^
  symbol:   variable ActionBar
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:385: error: cannot find symbol
                            | ActionBar.DISPLAY_SHOW_HOME
                              ^
  symbol:   variable ActionBar
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:386: error: cannot find symbol
                            | ActionBar.DISPLAY_SHOW_TITLE
                              ^
  symbol:   variable ActionBar
  location: class MultiImageChooserActivity
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:388: error: package ActionBar does not exist
            actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
                                                                      ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:463: error: incompatible types: MultiImageChooserActivity cannot be converted to Context
                ImageView temp = new SquareImageView(MultiImageChooserActivity.this);
                                                                              ^
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:601: error: cannot find symbol
                setResult(RESULT_CANCELED, data);
                          ^
  symbol:   variable RESULT_CANCELED
  location: class MultiImageChooserActivity.ResizeImagesTask
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:613: error: cannot find symbol
                setResult(RESULT_OK, data);
                          ^
  symbol:   variable RESULT_OK
  location: class MultiImageChooserActivity.ResizeImagesTask
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:616: error: cannot find symbol
                setResult(RESULT_CANCELED, data);
                          ^
  symbol:   variable RESULT_CANCELED
  location: class MultiImageChooserActivity.ResizeImagesTask
D:\MYPROJECTPATH\android\capacitor-cordova-android-plugins\src\main\java\com\synconset\MultiImageChooserActivity.java:620: error: cannot find symbol
            finish();
            ^
  symbol:   method finish()
  location: class MultiImageChooserActivity.ResizeImagesTask
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.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
43 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 12s
27 actionable tasks: 21 executed, 6 up-to-date