Skip to content

The react-navigation picture resource may cause a package error? #1976

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

Closed
liuweiGL opened this issue Jun 23, 2017 · 52 comments
Closed

The react-navigation picture resource may cause a package error? #1976

liuweiGL opened this issue Jun 23, 2017 · 52 comments

Comments

@liuweiGL
Copy link

liuweiGL commented Jun 23, 2017

01:22:43.077 [DEBUG] [org.gradle.api.Project] ERROR: D:\Android\wlApp\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png uncompiled PNG file passed as argument. Must be compiled first into .flat file.
01:22:43.077 [DEBUG] [org.gradle.api.Project] ERROR:  failed parsing overlays
01:22:43.077 [ERROR] [org.gradle.api.Project] ERROR: D:\Android\wlApp\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png uncompiled PNG file passed as argument. Must be compiled first into .flat file.
ERROR:  failed parsing overlays

01:22:43.078 [ERROR] [org.gradle.api.Task] Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:803)
        at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:547)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:299)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:74)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        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:242)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:611)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:566)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
aapt2 link -I
@tmxdyf
Copy link

tmxdyf commented Jul 3, 2017

我也遇见相同的问题...不知如何解决

@n8ebel
Copy link

n8ebel commented Jul 14, 2017

I don't know if react-navigation is necessarily the root cause, but I'm seeing this issue as well. It occurs when using the updated gradle version and plugin for Android Studio 3.0.

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'

@ssputay
Copy link

ssputay commented Aug 25, 2017

Getting same error on Android Studio 3.0.

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
classpath 'com.android.tools.build:gradle:3.0.0-beta3'

@agrosner
Copy link

for now in your top-level gradle.properties file add this line: android.enableAapt2=false which essentially uses the old aapt for resources.

@xMikeTx
Copy link

xMikeTx commented Aug 29, 2017

using this workaround leads to:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processProductionReleaseResources'.
.....
.....
Caused by: org.gradle.tooling.BuildException: Failed to execute aapt

So at least for me this only shifted the issue

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
classpath 'com.android.tools.build:gradle:3.0.0-beta3'

@agrosner
Copy link

what is rest of the error. probably something else in your project causing the true error

@xMikeTx
Copy link

xMikeTx commented Aug 29, 2017

Seems like this only happens on production builds, so maybe it has something todo with proguard.
already set:
shrinkResources false

crashlog.txt

update
Issue happens only in release builds. Also posted it on stackoverflow:
https://stackoverflow.com/questions/45954209/issues-with-resources-generated-by-react-in-android-studio-3
since this is blocking our upgrade.

update2
build.gradle.txt
package.json.txt

updated to:

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
classpath 'com.android.tools.build:gradle:3.0.0-beta4'

Still having issues.

update3
@agrosner
I finally found the problem why the workaround was not working. I had resources used in react, also defined in my android drawable folder.

-> workaround works for me now, although I am not happy that I have to use it.

@jeveloper
Copy link

Gradle tool 3.0.0 beta 6 and android.enableAapt2=false flag in properties now works like a charm

@kelset
Copy link

kelset commented Oct 30, 2017

Quick update: the error is still present with the freshly released Android Studio 3.0, gradle 4.1 & gradle tools 3.0.0 (build tools 26.0.2).

I'm investigating on why it happens, it's clearly related to node_modules_reactnavigation_src_views_assets_backicon.png, but the error uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays. doesn't really say much to me... nor apparently anywhere around the internet: most of the issues/SO answers I found around all declared as solution to "go back" to APPT via android.enableAapt2=false.

It's clearly related to AAPT2, the new version present in gradle tools 3.0 - but even the migration guide doesn't seem to offer an explanation for this kind of error. This SO answer seems to provide some more details but, yeah, until better explanations, please keep using android.enableAapt2=false.

Sorry, something went wrong.

@jcampalo
Copy link

jcampalo commented Oct 31, 2017

I'm having same issue, but android.enableAapt=false doesn't work for me, where did you put that? in gradle.properties files?

My bad, it should be android.enableAapt2=false instead of android.enableAapt=false.

Anyway I consider this a weird workaround and it's almost clear that is an issue with gradle 3.

Sorry, something went wrong.

@figgcoder
Copy link

figgcoder commented Nov 7, 2017

We are facing same issues even after setting
android.enableAapt2=false in gradle.properties.

Do I need to do something else after setting the property to make it work?

@xMikeTx how did you solve the problem. I am facing the same issue as you after setting enableAapt2=false in gradle.properties file.

Appreciate any help.

Following is my error

`/Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/res/merged/release/drawable-hdpi-v4/node_modules_reactnavigation_src_views_assets_backicon.png: error: Duplicate file.
/Users/sachingupta/Development/figg/figgapp/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.

Task :app:processReleaseResources
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor907.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
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:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
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:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
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:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /Users/sachingupta/Library/Android/sdk/build-tools/27.0.0/aapt with arguments {package -f --no-crunch -I /Users/sachingupta/Library/Android/sdk/platforms/android-26/android.jar -M /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/manifests/full/release/x86/AndroidManifest.xml -S /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/res/merged/release -m -J /Users/sachingupta/Development/figg/figgapp/android/app/build/generated/source/r/release -F /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/res/release/resources-x86Release.ap_ -G /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/proguard-rules/release/aapt_rules.txt --custom-package com.figg -0 apk --output-text-symbols /Users/sachingupta/Development/figg/figgapp/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.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
... 47 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing process /Users/sachingupta/Library/Android/sdk/build-tools/27.0.0/aapt with arguments {package -f --no-crunch -I /Users/sachingupta/Library/Android/sdk/platforms/android-26/android.jar -M /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/manifests/full/release/x86/AndroidManifest.xml -S /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/res/merged/release -m -J /Users/sachingupta/Development/figg/figgapp/android/app/build/generated/source/r/release -F /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/res/release/resources-x86Release.ap_ -G /Users/sachingupta/Development/figg/figgapp/android/app/build/intermediates/proguard-rules/release/aapt_rules.txt --custom-package com.figg -0 apk --output-text-symbols /Users/sachingupta/Development/figg/figgapp/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/sachingupta/Library/Android/sdk/build-tools/27.0.0/aapt'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:380)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
... 9 more

FAILURE: Build failed with an exception.

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

Failed to execute aapt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

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

BUILD FAILED in 1m 9s
176 actionable tasks: 176 executed
`

@xMikeTx
Copy link

xMikeTx commented Nov 7, 2017

@figgcoder Does this happen only in the release build? For me it did.

I think that happens because you added the mentioned resource files in the react project and in the android project.

I solved it by removing all images that are used in the react bundle from the android project. This leads however to that behavior that the resources are not showing in the debug build, but at least the production build works.

@figgcoder
Copy link

@xMikeTx Thank you for the quick reply. this only happens with release build.

I am new to react and don't understand what do you mean by android project and react project. I only added above library by using react link command. It will be helpful if you can provide path of folders where I can try by removing these files.

@xMikeTx
Copy link

xMikeTx commented Nov 7, 2017

Okay, same here, also my first and last ;) project.
I have a folder structure like

project
->node_modules
->resources[1]
-> ...
->android -> app -> src -> main -> res -> drawableXXXX [2]

I added my resources to the resources[1] and also in one of the drawable[2] folders which caused my problem. So I removed all duplicate resources from the drawable[2] folders

@react-navigation react-navigation deleted a comment from kesha-antonov Nov 7, 2017
@rtman
Copy link

rtman commented Nov 9, 2017

I encountered this issue as well, but the android.enableAapt2=false in gradle.properties has fixed it. Don't really like having to do this, so hopefully a real fix comes through.

@rochapablo
Copy link

rochapablo commented Nov 14, 2017

What exactly should I do with those app/src/main/res/drawable folders? delete or just edit each file?

I have add android.enableAapt2=false to the android/gradle.properties but still getting

...node_modules_reactnavigation_src_views_assets_backicon.png: error: Duplicate file.
...node_modules_reactnavigation_src_views_assets_backicon.png: Original is here. The version qualifier may be implied.

@sujayjaju
Copy link

sujayjaju commented Nov 16, 2017

This is what I discovered:

  • Only happens for release builds.
  • This issues seems to stem from duplicate assets in the drawable folder: fails with the error "Duplicate file"

To make it work, before running gradlew assembleRelease delete all images from

  • 'android/app/src/main/res/drawable-mdpi'
  • 'android/app/src/main/res/drawable-hdpi'
  • 'android/app/src/main/res/drawable-xhdpi'
  • 'android/app/src/main/res/drawable-xxhdpi'
  • 'android/app/src/main/res/drawable-xxxhdpi'

Or, generate signed APKs using android studio. That works as well for some reason.

@kelset
Copy link

kelset commented Nov 16, 2017

Hi @sujayjaju thanks for your comment - does you app works smoothly without the assets in those folders?

@sujayjaju
Copy link

@kelset Yes, the assets do carry over and the app works smoothly.

@kelset
Copy link

kelset commented Nov 16, 2017

Ok so I guess that we could try removing those assets completely? Will investigate/test.

@rochapablo
Copy link

rochapablo commented Nov 16, 2017

@sujayjaju, generate signed APKs using android studio was the best alternative until now.

Android Studio > Build > Generate Signed APK...

@tremolando
Copy link

Still having this issue. Any ETA for a proper fix instead of workaround?

@kelset
Copy link

kelset commented Nov 21, 2017

ETA for a proper fix

Currently, I can't understand why this happens in the first place, as I said here #1976 (comment) - so @soundstage if you have any insight please share it.

@Almouro
Copy link

Almouro commented Nov 27, 2017

Posted a similar issue on React Native here: facebook/react-native#16906, but no good answer yet.

When Android Studio and Gradle are up to date, requiring images on Android fails.

@afilp
Copy link

afilp commented Nov 28, 2017

I added android.enableAapt2=false, but now I get this message (when doing 'assembleRelease') for all packages and fails:

 > Could not resolve project :react-native-fetch-blob.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-fetch-blob:
          - Configuration 'debugApiElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'releaseStaging' and found incompatible value 'debug'.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'java-runtime' and found incompatible value 'java-api'.

It seems that this happens due to the releaseStaging buildType?

Any ideas?

@afilp
Copy link

afilp commented Nov 28, 2017

Indeed, when I removed the releaseStaging buildType, it worked.

This should not be the right approach though... I understand that when we do assembleRelease then it tries to create both release and releaseStaging apks?

@PaperMonster
Copy link

Adding android.enableAapt2=false did solve the problem for me. Thanks a lot!

@afilp I think your problem is a different one. Newer Gradle plugin versions requires all app's build configurations to match dependencies'. Google suggested adding matchingFallbacks=[<build configs>] to any custom build configurations that dependencies don't have so they have alternatives to fallback to. Example brought from docs:

// In the app's build.gradle file.
android {
    buildTypes {
        debug {}
        release {}
        staging {
            // Specifies a sorted list of fallback build types that the
            // plugin should try to use when a dependency does not include a
            // "staging" build type. You may specify as many fallbacks as you
            // like, and the plugin selects the first build type that's
            // available in the dependency.
            matchingFallbacks = ['debug', 'qa', 'release']
        }
    }
}

@gengjiawen
Copy link

gengjiawen commented Dec 6, 2017

Enable android.enableAapt2=false is not a best solution, it will crash your app if you use vector drawable on pre-lollipop devices.

Edit:

  1. I created a issue to google, hope will get any answer, https://issuetracker.google.com/issues/70258562.
  2. Repro repo: https://github.com/gengjiawen/aaptv2-crash.

@ilariowiz
Copy link

ilariowiz commented Dec 8, 2017

I'm having the same issue and I can't generate signed release apk and this is a BIG issue.

The error is:

uncompiled PNG file passed as argument. Must be compiled first into .flat file..
failed parsing overlays

relative to: ../android/app/build/intermediates/res/merged/release/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png

setting android.enableAapt2=false does NOT work for me
I'm generating the apk from Android Studio

There is a workaround? I already test the previous workaround in this page

I have a deadline and I can not create the apk

@kelset
Copy link

kelset commented Dec 8, 2017

@Ilario17 in the previous comments there are some other "workarounds". Like #1976 (comment)

@ilariowiz
Copy link

@kelset I already test the previous workaround and none seem to works

@gengjiawen
Copy link

You need put it to the right location and try to build it using command.

@ilariowiz
Copy link

@gengjiawen the file node_modules_reactnavigation_src_views_assets_backicon.png is automatically created during the build.. so I'm not putting it in the wrong position

@gengjiawen
Copy link

gengjiawen commented Dec 8, 2017

I mean the gradle.properties, it's in android root project. And try to use ./gradlew clean assembleRelease if you are not using multi flavor.

@ilariowiz
Copy link

@gengjiawen Can you explain how I should edit gradle.properties

@kelset
Copy link

kelset commented Dec 8, 2017

@Ilario17 #1976 (comment)

@ilariowiz
Copy link

@kelset @gengjiawen ok maybe you are not reading my post well.

@kelset
Copy link

kelset commented Dec 8, 2017

ok maybe you are not reading my post well.

What do you mean? Your first comment #1976 (comment) is literally detailing the same error that started this issue and that I re-commented here #1976 (comment)

And android.enableAapt2=false is the current workaround.
You could not use Gradle Tools 3, since that's what's causing it.

@ilariowiz
Copy link

In my first comment I have already said that android.enableAapt2=false does not work for me.

It doesn't works because it generates a lot of other errors.

This is the only workaround?

@kelset
Copy link

kelset commented Dec 8, 2017

In my first comment I have already said that android.enableAapt2=false does not work for me.

Reason why me and @gengjiawen tried to help you figure out why it doesn't work for you, by assuming you were writing android.enableAapt2=false not in the right place, or not cleaning up the build before trying again.

Since it looks like it is not the case, I suggest you investigate your Android Studio configuration and your gradle file.

@gengjiawen
Copy link

what's the new error?

@ilariowiz
Copy link

ilariowiz commented Dec 8, 2017

I'm putting android.enableAapt2=false in the right place.

the new errors:

/Users/Ilario/Desktop/proj/android/app/build/intermediates/res/merged/release/drawable-mdpi-v4/node_modules_reactnavigation_src_views_assets_backicon.png
Error:error: Duplicate file.
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: 
Error while executing process /Users/Ilario/Library/Android/sdk/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /Users/Ilario/Library/Android/sdk/platforms/android-26/android.jar -M 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/manifests/full/release/AndroidManifest.xml -S 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/res/merged/release -m -J 
/Users/Ilario/Desktop/proj/android/app/build/generated/source/r/release -F 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/res/release/resources-release.ap_ --custom-package com.mypackage -0 apk --output-text-symbols 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/symbols/release --no-version-vectors}
Error:com.android.ide.common.process.ProcessException: 
Error while executing process /Users/Ilario/Library/Android/sdk/build-tools/26.0.2/aapt with arguments {package -f --no-crunch -I /Users/Ilario/Library/Android/sdk/platforms/android-26/android.jar -M 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/manifests/full/release/AndroidManifest.xml -S 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/res/merged/release -m -J /Users/Ilario/Desktop/proj/android/app/build/generated/source/r/release -F
/Users/Ilario/Desktop/proj/android/app/build/intermediates/res/release/resources-release.ap_ --custom-package com.mypackage -0 apk --output-text-symbols 
/Users/Ilario/Desktop/proj/android/app/build/intermediates/symbols/release --no-version-vectors}
Error:org.gradle.process.internal.ExecException: Process 'command '/Users/Ilario/Library/Android/sdk/build-tools/26.0.2/aapt'' finished with non-zero exit value 1
Error:Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt

@kelset
Copy link

kelset commented Dec 8, 2017

have you tried to delete the content as proposed here? #1976 (comment)

Or to simply go into your node_modules/react-navigation/... folder and remove those image assets?

@ilariowiz
Copy link

Yes I tried to remove images from app/src/main/res but every time I build the images are recreated so..

removing from node_modules does not create problems with the module itself?

Are the other errors related to Duplicate files?

@kelset
Copy link

kelset commented Dec 8, 2017

Are the other errors related to Duplicate files?

"Error:error: Duplicate file." 2nd line.

removing from node_modules does not create problems with the module itself?

It depends, I think it's worth a try in your case, since apparently the standard way doesn't work.

If that doesn't work, can you post your build.gradle file? both of them? and the gradle.properties?

@ilariowiz
Copy link

ilariowiz commented Dec 9, 2017

@kelset @gengjiawen Ok I re-delete images from app/src/main/res and this time they did not recreate themselves, this time Gradle project sync failed no matter what i do and I have this error:

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/arch/lifecycle/BuildConfig;

I have already looked at all the dependencies of play-services (used only by one module)
All modules have the same compileSdkVersion (26) and the same buildToolsVersion (26.0.2)

This is my dependencies inside my build.gradle:

dependencies {
    compile project(':react-native-sensitive-info')
    compile project(':react-native-camera')
    compile project(':react-native-media-meta')
    compile project(':react-native-video')
    compile project(':react-native-vector-icons')
    compile (project(':react-native-push-notification')) {
        exclude group: 'com.google.android.gms:play-services-gcm:10.+'
    }
    compile ('com.google.android.gms:play-services-gcm:10.+') {
        force = true;
    }
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-fbsdk')
    compile project(':react-native-default-preference')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

I already tried to set play-services-gcm:11.2.6 for my build.gradle and push-notification build.gradle but the result is the same.

All modules that have support: appcompat, are using the version in my build.gradle

After some gradle clean, clean project and 'I hate android' , the app build but crash on start with:
RuntimeException: Unable to get provider com.facebook.internal.FacebookInitProvider BUT only on debug
in release mode I can't do the apk with this error:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/facebook/fbui/textlayoutbuilder/proxy/StaticLayoutProxy;

@gengjiawen
Copy link

The crash problem is with fbsdk, not related to this project.

@ilariowiz
Copy link

Yes now for sure is not related to this project. I've only update my situation

@gengjiawen
Copy link

The debug problem : you are not config fbsdk right. release problem : you are import some library twice.

@kelset
Copy link

kelset commented Dec 9, 2017

@Ilario17 it really looks like, as I already said, you have your Android configuration misconfigured.

You are using this issue as a chat, which pollutes the overall flow of keeping track of the issue and workarounds.
I highly suggest you move to Discord's Reactflux for your conversation with @gengjiawen and maybe even other people there that may help. I'm going to close this issue and open a new one - so that will be easier for everyone to check for workarounds and us to keep track of the issue without scrolling these many comments.

@kelset
Copy link

kelset commented Dec 9, 2017

Closing in favor of #3097

@kelset kelset closed this as completed Dec 9, 2017
@1c7
Copy link

1c7 commented Dec 15, 2017

@agrosner solution work for me!

for now in your top-level gradle.properties file add this line: android.enableAapt2=false which essentially uses the old aapt for resources.

Now I can finally Generating Signed APK for Android.
using React Native 0.51

@react-navigation react-navigation locked and limited conversation to collaborators Dec 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests