ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.09k stars 1.55k forks source link

Manifest merger failed on Android, but working fine on iOS #1428

Open dongdyang opened 3 years ago

dongdyang commented 3 years ago

Version

Tell us which versions you are using:

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.

prasad456 commented 3 years ago

I have the same issue with android, working iOS

BaderSerhan commented 3 years ago

Same here.

huaoguo commented 3 years ago

Same here.

mariobrubio commented 3 years ago

Same issue here @ivpusic any updates on this?

meiqi1992 commented 3 years ago

+1

meiqi1992 commented 3 years ago

@huaoguo @mariobrubio resovled?please help me ?

iKoru commented 3 years ago

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"/>

jaksonfact commented 3 years ago

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

jaksonfact commented 3 years ago

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,

memorybx commented 3 years ago

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.

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

PrasathRavichandran commented 2 years ago

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.

GoDeepBlue commented 2 years ago

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.

LeoAsher25 commented 2 years ago

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.

Michael-T30 commented 2 years ago

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

mattjbrill commented 2 years ago

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!