React-native: error: Duplicate file. Original is here. The version qualifier may be implied. With gradle assembleRelease

Created on 10 May 2018  路  35Comments  路  Source: facebook/react-native

Environment


Environment:
OS: macOS Sierra 10.12.6
Node: 9.11.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.2
react-native: 0.54.4 => 0.54.4

Steps to Reproduce

$ cd android && ./gradlew assembleRelease

Expected Behavior


A generated apk at the end.

Actual Behavior

Configure project :app
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/callsoft/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.2.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debu
g, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

Configure project :react-native-firebase
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/callsoft/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Configure project :react-native-image-picker
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/callsoft/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.2.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Configure project :react-native-image-resizer
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/callsoft/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.2.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Configure project :react-native-vector-icons
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/callsoft/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.2.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Task :app:processReleaseGoogleServices
Parsing json file: /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/google-services.json

Task :app:bundleReleaseJsAndAssets
Scanning folders for symlinks in /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/node_modules (11ms)
Scanning folders for symlinks in /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/no
de_modules (22ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: Writing bundle output to: /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/a
ndroid/app/build/intermediates/assets/release/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 18 asset files
bundle: Done copying assets

/Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res
/merged/release/drawable-hdpi-v4/node_modules_reactnavigation_src_views_assets_backicon.png: error: Duplicate file.
/Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res/merged/release/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Original is here. The version qualifier may be implied.

FAILURE: Build failed with an exception.

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

    Failed to process resources, see aapt output above for details.

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processReleaseResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    Caused by: org.gradle.tooling.BuildException: Failed to process resources, see aapt output above for details.
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:512)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:249)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 29 more
    Caused by: com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:491)
    ... 42 more
    Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /Users/callsoft/Library/Android/sdk/build-tools/27.0.3/aapt with arguments {package -f --no-crunch -I /Users/callsoft/Library/Android/sdk/platforms/android-26/android.jar -M /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/manifests/full/release/AndroidManifest.xml -S/Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res/merged/release -m -J /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/generated/source/r/release -F /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res/release/resources-release.ap_ --custom-package com.cyndyporter -0 apk --output-text-symbols /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/symbols/release --no-version-vectors}
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.internal.aapt.AbstractAapt.link(AbstractAapt.java:34)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:807)
    ... 44 more
    Caused by: com.android.ide.common.process.ProcessException: Error while executing process /Users/callsoft/Library/Android/sdk/build-tools/27.0.3/aapt with arguments {package -f --no-crunch -I /Users/callsoft/Library/Android/sdk/platforms/android-26/android.jar -M /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/manifests/full/release/AndroidManifest.xml -S /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res/merged/release -m -J /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/generated/source/r/release -F /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/res/release/resources-release.ap_ --custom-package com.cyndyporter -0 apk --output-text-symbols /Users/callsoft/Documents/Mobulous/Projects/React/cyndy-porter-style-photography/android/app/build/intermediates/symbols/release --no-version-vectors}
    at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1237)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:911)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:822)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:664)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:48)
    at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:58)
    Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/callsoft/Library/Android/sdk/build-tools/27.0.3/aapt'' finished with non-zero exit value 1
    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:382)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
    ... 9 more

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

BUILD FAILED in 4m 58s
62 actionable tasks: 4 executed, 58 up-to-date

Bug Help Wanted Android Locked

Most helpful comment

Add the following code to file node_modules/react-native/react.gradle :

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

inside def currentBundleTask = tasks.create(...

Found this temporary solution here.

All 35 comments

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

+1, same error

Add the following code to file node_modules/react-native/react.gradle :

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

inside def currentBundleTask = tasks.create(...

Found this temporary solution here.

any solution yet?

@zszep yes
@PierreBresson code solved it

Here's how i generate signed apk for android now:

  1. first i update jsbundle by this command
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
  1. then Generate Signed apk as usual with android studio.

@akamahesh This is basically a hack. Tried it. It works. But when i updated react-native to a newer version, the change was overwritten. Also, the node_modules folder is not under source control.

@akamahesh It not works.

@zszep Yes its a hack!
And it is not recommended to make any changes in node-modules's gradle.
It will get overwritten every time you run npm install but until i found a solid way to do it.. m gonna stay with this.

@zszep @akamahesh You could make a patch directory in your project root where you would keep your updated version of the react.gradle file. Then in your package.json, cp the file to ./node_modules/react-native/react.gradle in your postinstall. Still a hack, but at least you can still just run npm/yarn install as needed and not have to manually reapply the fix.

@ckwilhelm Right now I'm doing exactly as you suggest. But I don't like it. What if for some reasons the gradle file changes and I overwrite it with the old file.

It has been included in the latest react-native release.

@zszep can you confirm this has been fixed in the latest release? thank you.

Right now I am on vacation. Will check it as soon as I return home.

@zszep can you confirm this has been fixed in the latest release? thank
you.

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/facebook/react-native/issues/19211#issuecomment-405469507

--
Voditelj Slu啪be za informatiku KBC Osijek

Follow this:-

https://medium.com/@nhancv/react-native-build-release-duplicate-file-original-is-here-the-version-qualifier-may-be-implied-115e967c59e6

@PierreBresson thank you :)

I moved image files from drawble-mdpi to drawable-hdpi directory. Now it is working fine!

Or alternatively delete drawable-mdpi folder, it works too

Same problem, is there a proper solution ?

same error

@PierreBresson
seems not work with 0.57.0 , work fine with 0.55 馃

Not working on 0.55.4 either

@PierreBresson solution worked for me with RN 0.57.2 and patch-package
Here's the react-native+0.57.2.patch file if someone needs it:

patch-package
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -72,6 +72,22 @@ afterEvaluate {
             enabled config."bundleIn${targetName}" ||
                 config."bundleIn${variant.buildType.name.capitalize()}" ?:
                 targetName.toLowerCase().contains("release")
+
+            doLast {
+                def moveFunc = { resSuffix ->
+                    File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
+                    if (originalDir.exists()) {
+                        File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
+                        ant.move(file: originalDir, tofile: destDir)
+                    }
+                }
+                moveFunc.curry("ldpi").call()
+                moveFunc.curry("mdpi").call()
+                moveFunc.curry("hdpi").call()
+                moveFunc.curry("xhdpi").call()
+                moveFunc.curry("xxhdpi").call()
+                moveFunc.curry("xxxhdpi").call()
+            }
         }

         // Expose a minimal interface on the application variant and the task itself:

well, i solved in this way:

  1. in gradle-wrapper.properties use
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
  2. in gradle. properties remove enableAappt2=false
  3. in android>build.gradle set
`buildscript {
    repositories {

        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        } 
        jcenter()
    }
    dependencies {
       classpath 'com.android.tools.build:gradle:3.2.0'

    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {

            url "$rootDir/../node_modules/react-native/android"
        }

        maven { url "https://jitpack.io" }
         maven {
            url 'https://maven.google.com/'
            name 'Google'
        }  
        jcenter()
        google()
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.31.0'
                force 'com.google.android.gms:play-services-base:11.8.0'
                force 'com.google.android.gms:play-services-maps:11.8.0'
                force 'com.google.android.gms:play-services-gcm:11.8.0'
                force 'com.google.android.gms:play-services-location:11.8.0'
            }
        }
    }
}
subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.1.0"
        }
     }
  }
}
`
  1. gradlew clean , generate bundle and build using android studio
> cd PROJECT_DIR
> react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

> rm -rf android/app/src/main/res/drawable-xxxhdpi android/app/src/main/res/drawable-xxhdpi android/app/src/main/res/drawable-xhdpi android/app/src/main/res/drawable-mdpi android/app/src/main/res/drawable-hdpi
> cd android && ./gradlew assembleRelease

Working for me.

Or:

> sudo vi ~/.zshrc

And add alias:

alias abundle='rm android/app/src/main/assets/index.android.bundle && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && rm -rf android/app/src/main/res/drawable-xxxhdpi android/app/src/main/res/drawable-xxhdpi android/app/src/main/res/drawable-xhdpi android/app/src/main/res/drawable-mdpi android/app/src/main/res/drawable-hdpi && cd android && ./gradlew assembleRelease'

Save & exit.

> source ~/.zshrc

If you have bash, add it to the ~/.bashrc alias.

Now you can create a bundle with one command

> abundle

Profit 馃樄

@Smolyan91 but with this solution u still use enableAappt2=false that will remove at the end of 2018

guys, do you have any proper solution without patching node_modules?

@Smolyan91 but with this solution u still use enableAappt2=false that will remove at the end of 2018

Probably, have to come up with another crutch )

I've upgraded my react native to 57.7
react to 16.3.2
build tools gradle to 3.2.0
gradle to 4.6

and removed all drawable* folders

rm -rf android/app/src/main/res/drawable-*

from gradle.properties remove android.enableAapt2=false

use the following command to bundle assets:

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/

now generate release apk using following command.
cd android && ./gradlew assembleRelease && cd ..

Note: bundled assets folder in RN > 57 has changed to android/app/build/intermediates/res/merged/release/

Thanks @GaneshSaiKumar !

Please write guide how to right update gradle to version 5, and java 11.

WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.

@7laria's answer worked for me. Well, part of the answer did the trick. Along with step 1 and 2, just updated com.android.tools.build:gradle to 3.2.0

@ckwilhelm Right now I'm doing exactly as you suggest. But I don't like it. What if for some reasons the gradle file changes and I overwrite it with the old file.

https://www.npmjs.com/package/patch-package

It still has some limitations, but at least its not a full file overwrite...

We are landing the fix for this right now.

Was this page helpful?
0 / 5 - 0 ratings