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

Capacitor with third-party AndroidX library #2082

Closed
Nasicus opened this issue Oct 23, 2019 · 6 comments
Closed

Capacitor with third-party AndroidX library #2082

Nasicus opened this issue Oct 23, 2019 · 6 comments

Comments

@Nasicus
Copy link

Nasicus commented Oct 23, 2019

Roughly said I have the following project:

  • Out of the box app with create-react-app & typescript (npx create-react-app my-app --typescript)
  • Added capacitor (npm install --save @capacitor/core @capacitor/cli)
  • Initialized capacitor (npx cap init)
  • Added Android (npx cap add android)
  • Created a custom plugin (npx @capacitor/cli plugin:generate)
  • referenced this plugin in my package.json of the react app ("capsal-msal-plugin": "file:capsal-msal-plugin")
  • added the third-party library which uses androidx to the build.gradle file of my plugin, i.e.
dependencies {
   implementation 'com.microsoft.identity.client:msal:1.0.+'
}

Now when I try to build Android I get the following error:

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.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-43:19 to override.

If you google this you quickly find, that his is an AndroidX issue:
https://stackoverflow.com/questions/51793345/android-material-and-appcompat-manifest-merger-failed

I tried various things (bascially all are from the SO thread above):

  • Using Android Studio with the command Refactor => Migrate To Android X
  • enable jetifier in the gradle.properties

None of it worked, it just resulted in different errors.

So my question:
Did anyone ever manage to add a third-party library which uses AndroidX? If so can you please tell me how this can be achieved?

I pushed my sample project to this repository:
https://github.com/Nasicus/capsal

@Nasicus Nasicus changed the title Capacitor with third-party AndroidX plugin Capacitor with third-party AndroidX library Oct 23, 2019
@jcesarmobile
Copy link
Member

Android X can’t be used just for one dependency, it has to be used for al dependencies in all plugins and modules, including Capacitor itself, which doesn’t support it yet.

#1937

@Nasicus
Copy link
Author

Nasicus commented Oct 23, 2019

@jcesarmobile I know it doesn't work yet. I hoped there is a workaround for it. Especially because I read something in #1937 (comment)

@priyankpat
Copy link
Contributor

I have a PR #2045 submitted got AndroidX support. Maybe try it as a workaround?

@Nasicus
Copy link
Author

Nasicus commented Oct 25, 2019

Thanks @PR1YANKPAT3L is there an easy was of how to use your version? do I need to build it locally and stuff?

@priyankpat
Copy link
Contributor

priyankpat commented Oct 25, 2019

I simply referenced the repository locally. This is my current setup.

-- projects
---- capacitor (forked repo)
---- main-project (current project)

I ran from main-project the following: npm i ../capacitor/android --save. Once installed, you can run: npx cap sync.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 13, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants