react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

Manifest merger failed on Android, but working fine on iOS

Open dongdyang opened this issue 5 years ago • 15 comments

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.35
  • react-native v0.62.0

Platform

My code is working fine on iOS with crop image package. However, when i try to compile android version. I got this error. Currently i am using

android studio 4.0, 'com.android.tools.build:gradle:4.0.1', gradle-wrapper.properties, update the path to services.gradle.org, Version is 6.1.1, Android SDK is version 29.

Actual behaviour

Manifest merger failed : Attribute activity#com.yalantis.ucrop.UCropActivity@theme value=(@style/Theme.AppCompat.Light.NoActionBar) from [:react-native-image-crop-picker] AndroidManifest.xml:31:13-69
	is also present at [com.github.LuckSiege.PictureSelector:picture_library:2.5.6] AndroidManifest.xml:55:13-58 value=(@style/Base.Theme.NoActionBar).
	Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:29:9-31:72 to override.

Steps to reproduce

The code is private and huge project. It is hard to break it down. The thing here is it is working well on iOS. When switching to android, this error get out.

dongdyang avatar Oct 04 '20 05:10 dongdyang

I have the same issue with android, working iOS

prasad456 avatar Jan 08 '21 07:01 prasad456

Same here.

BaderSerhan avatar Feb 15 '21 21:02 BaderSerhan

Same here.

huaoguo avatar Feb 23 '21 02:02 huaoguo

Same issue here @ivpusic any updates on this?

mariobrubio avatar Feb 23 '21 21:02 mariobrubio

+1

meiqi1992 avatar Apr 04 '21 05:04 meiqi1992

@huaoguo @mariobrubio resovled?please help me ?

meiqi1992 avatar Apr 05 '21 10:04 meiqi1992

HI guys, I also faced this error message with other than this library and I resolved issue.

Consider to add the code below on AndroidManifest.xml

<activity android:name="com.yalantis.ucrop.UCropActivity" tools:remove="android:theme"/>

iKoru avatar May 16 '21 03:05 iKoru

I am also facing same issue.., any solution...,?

jaksonfact avatar Jul 23 '21 12:07 jaksonfact

HI guys, I also faced this error message with other than this library and I resolved issue.

Consider to add the code below on AndroidManifest.xml

<activity android:name="com.yalantis.ucrop.UCropActivity" tools:remove="android:theme"/>

This is not working for me , If i enter your code below Manifiest i got error like,

  • What went wrong: Execution failed for task ':app:generateDebugBuildConfig'.

Failed to calculate the value of task ':app:generateDebugBuildConfig' property 'buildConfigPackageName'. Failed to query the value of property 'packageName'.

jaksonfact avatar Jul 23 '21 12:07 jaksonfact

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.35
  • react-native v0.62.0

Platform

My code is working fine on iOS with crop image package. However, when i try to compile android version. I got this error. Currently i am using

android studio 4.0, 'com.android.tools.build:gradle:4.0.1', gradle-wrapper.properties, update the path to services.gradle.org, Version is 6.1.1, Android SDK is version 29.

Actual behaviour

Manifest merger failed : Attribute activity#com.yalantis.ucrop.UCropActivity@theme value=(@style/Theme.AppCompat.Light.NoActionBar) from [:react-native-image-crop-picker] AndroidManifest.xml:31:13-69
	is also present at [com.github.LuckSiege.PictureSelector:picture_library:2.5.6] AndroidManifest.xml:55:13-58 value=(@style/Base.Theme.NoActionBar).
	Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:29:9-31:72 to override.

Steps to reproduce

The code is private and huge project. It is hard to break it down. The thing here is it is working well on iOS. When switching to android, this error get out.

你好:请问您遇到的这个问题,最后怎么解决的?我也遇到一样的问题

memorybx avatar Jul 29 '21 09:07 memorybx

I also faced this kind of issue, but I resolved it by adding some configuration inside our project AndroidManifest.xml file.

Step 1:

Create one new xml folder inside your project's (android/app/src/main/res/), create a new XML file (file_path.xml) and copy/paste these lines of code.

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

Step 2:

Inside your project AndroidManifest.xml file, add the providers and use the XML file in it.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="your_app_package_name">
...
<application
...
>
 <provider
            android:authorities="${applicationId}.provider"
            android:name="androidx.core.content.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_path"
                tools:replace="android:resource"/>
 </provider>

</application>
</manifest>

Then, run your project, It will work without error in android.

PrasathRavichandran avatar Nov 17 '21 11:11 PrasathRavichandran

Any update on this issue? I have tried the various fixes listed in this thread and this fix: https://githubmemory.com/index.php/repo/baronha/react-native-multiple-image-picker/issues/52.

Issue still persists on Android.

Build error is below: Manifest merger failed : Attribute activity#com.yalantis.ucrop.UCropActivity@theme value=(@style/Theme.AppCompat.Light.NoActionBar) from [:react-native-image-crop-picker] AndroidManifest.xml:30:13-69 is also present at [io.github.lucksiege:pictureselector:v2.7.3-rc08] AndroidManifest.xml:55:13-58 value=(@style/Base.Theme.NoActionBar). Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:28:9-30:72 to override.

GoDeepBlue avatar May 02 '22 03:05 GoDeepBlue

Any update on this issue? I have tried the various fixes listed in this thread and this fix: https://githubmemory.com/index.php/repo/baronha/react-native-multiple-image-picker/issues/52.

Issue still persists on Android.

Build error is below: Manifest merger failed : Attribute activity#com.yalantis.ucrop.UCropActivity@theme value=(@style/Theme.AppCompat.Light.NoActionBar) from [:react-native-image-crop-picker] AndroidManifest.xml:30:13-69 is also present at [io.github.lucksiege:pictureselector:v2.7.3-rc08] AndroidManifest.xml:55:13-58 value=(@style/Base.Theme.NoActionBar). Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:28:9-30:72 to override.

Have you fixed it? I have tried and I cant fix it, too.

LeoAsher25 avatar May 10 '22 02:05 LeoAsher25

Maybe this answer will let you know why the build failed on android.

Michael-T30 avatar May 24 '22 09:05 Michael-T30

Hi everyone.

I am not a maintainer of this package, so please do not put too much hope in my response.

My understanding is that Android SDK 31 now enforces a requirement, and silences the errors, which is causing an issue with AndroidManifest.xml files in many projects. The issue is that a android:exported element needs to be explicitly defined for entry types activity, service,receiver, and provider. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

So, some examples!

If your project's ./android/app/src/main/AndroidManifest.xml file looks something like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.some.project">

    <application
        android:name="com.some.project.MainApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher_res"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/SplashTheme"
        android:usesCleartextTraffic="true"
        tools:replace="android:allowBackup">

        <activity
            android:name="com.some.project.MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="userPortrait"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</manifest>

Then to patch the issue with the react-native-image-crop-picker package, you must do...

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.some.project">

    <application
        android:name="com.some.project.MainApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher_res"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/SplashTheme"
        android:usesCleartextTraffic="true"
        tools:replace="android:allowBackup">

        <activity
            android:name="com.some.project.MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="userPortrait"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:exported="false"
            tools:node="merge"
            tools:overrideLibrary="com.reactnative.ivpusic.imagepicker"
        />
</manifest>

Please notice in the opening manifest tag, you need to have xmlns:tools="http://schemas.android.com/tools". This allows tools:node="merge" to add the missing required android:exported element.

Hope that helps!

mattjbrill avatar Sep 08 '22 00:09 mattjbrill