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

Execution failed for task ':app:processReleaseResources'. #19239

Open
rodrigofbm opened this Issue May 13, 2018 · 47 comments

Comments

Projects
None yet
@rodrigofbm
Copy link

rodrigofbm commented May 13, 2018

Environment:

OS: Linux 4.13
Node: 9.10.1
Yarn: 1.6.0
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)

react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Steps to Reproduce

./gradlew assembleRelease

Expected Behavior

make work???

Actual Behavior

The log:

/home/rodrigo/Documentos/React-Native/Projetos-Independentes/PetShop/PetShop/android/app/build/intermediates/res/merged/release/drawable-mdpi/node_modules_reactnativecheckbox_img_ic_check_box_outline_blank.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.


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.GeneratedMethodAccessor59.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        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: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 1 more
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:463)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:415)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt

build.gradle:

"apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.petshop"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

	signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
			signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-device-info')
    compile project(':react-native-camera')
    compile project(':react-native-text-input-mask')
    compile project(':react-native-push-notification')
    compile project(':react-native-image-picker')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.0.2"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}`

UPDATE

I've seted android.enableAapt2 = false in gradle.properties file, but now I'm receiving this log:

> Task :react-native-camera:extractReleaseAnnotations
Warning: com.google.android.cameraview.CameraView.Flash: The typedef annotation should have @Retention(RetentionPolicy.SOURCE)

/home/rodrigo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.0.2.aar/a8ac6386db44d95bb0127b060ca3ccbc/res/values-v24/values-v24.xml:3:5-157: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
    
/home/rodrigo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.0.2.aar/a8ac6386db44d95bb0127b060ca3ccbc/res/values-v24/values-v24.xml:4:5-135: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
    
/home/rodrigo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.0.2.aar/a8ac6386db44d95bb0127b060ca3ccbc/res/values-v26/values-v26.xml:13:5-16:13: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
    
/home/rodrigo/Documentos/React-Native/Projetos-Independentes/PetShop/PetShop/node_modules/react-native-device-info/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

/home/rodrigo/Documentos/React-Native/Projetos-Independentes/PetShop/PetShop/node_modules/react-native-device-info/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

/home/rodrigo/Documentos/React-Native/Projetos-Independentes/PetShop/PetShop/node_modules/react-native-device-info/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-device-info:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

Why is this happening?

@castaway2000

This comment has been minimized.

Copy link

castaway2000 commented May 13, 2018

i am also getting this exact same issue with this exact same step by step. i would LOVE to know why this is happening for release builds but not debug builds.

@rodrigofbm

This comment has been minimized.

Copy link

rodrigofbm commented May 13, 2018

For me this works:
add this code in /android/build.gradle

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.0.2"
        }
     }
  }
}

26.0.2 is the vs that I've seted in /android/app/build.gradle file for buildToolsVersion.
Give a shoot.

@FSPinho

This comment has been minimized.

Copy link

FSPinho commented May 16, 2018

@rodrigofbm, you workaround not works for me =/

* Where:
Build file '/home/felipe/Projects/personal/grioty/android/build.gradle' line: 33

* What went wrong:
A problem occurred configuring project ':app'.
> Android tasks have already been created.
  This happens when calling android.applicationVariants,
  android.libraryVariants or android.testVariants.
  Once these methods are called, it is not possible to
  continue configuring the model.

Can you explain what this code are doing? Perhaps I can understand what is happening with my project.
Thanks!

@rodrigofbm

This comment has been minimized.

Copy link

rodrigofbm commented May 17, 2018

@FSPinho try only this:

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
  }
}

@FSPinho

This comment has been minimized.

Copy link

FSPinho commented May 17, 2018

Thanks!
But the errors are occurring exactly due to this two lines.
compileSdkVersion 26
buildToolsVersion '26.0.2'

@rodrigofbm

This comment has been minimized.

Copy link

rodrigofbm commented May 18, 2018

Can you send me information about the development environment?
With the terminal open in the project folder: react-native info

@kkusanagi

This comment has been minimized.

Copy link

kkusanagi commented May 18, 2018

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 6.11.3
  Yarn: Not Found
  npm: 6.0.1
  Watchman: 4.9.0
  Xcode: Xcode 9.3.1 Build version 9E501
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: ^0.55.4 => 0.55.4


for my case, I uses below
Gradle v4.4
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.0'

compileSdkVersion = 27
buildToolsVersion = '27.0.3'

@rodrigofbm

This comment has been minimized.

Copy link

rodrigofbm commented May 18, 2018

So you have to change the code for:

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion '27.0.3'
            }
        }
    }
  }
}
@kkusanagi

This comment has been minimized.

Copy link

kkusanagi commented May 18, 2018

About that, I had tried it. still the same error result.

For Gradle v4.4.
the minimum compile version seems to be 27.0.3 or 27.1.0 either one.

It just like something linking to this problem after I install react-native-camera latest version. Forced to update to newer version in order to compile. And here it is, this problem show up.

@francisrod01 francisrod01 referenced this issue May 27, 2018

Closed

RN 0.55.4 android build error #19467

3 of 3 tasks complete
@pkhien95

This comment has been minimized.

Copy link

pkhien95 commented May 31, 2018

@kkusanagi I have the same problem after installing react-native-camera v1.1.4. Did you solve it?

@kkusanagi

This comment has been minimized.

Copy link

kkusanagi commented Jun 1, 2018

hi, @pkhien95 . This is how it work for me now by using react-native-camera v0.10.0.
About newest version, sorry, still got problem.

Environment:
OS: macOS High Sierra 10.13.4
Node: 6.11.3
Yarn: Not Found
npm: 6.0.1
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: ^0.51.1 => 0.51.1
react-native-camera: 0.10.0

In android android/gradle/wrapper/gradle-wrapper.properties change this
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Add below in android/gradle.properties to SOLVE this thread problem TEMPORARILY workaround. Need remove in future before year 2019.
android.enableAapt2=false

Then you may meet another error as duplicate file for drawable-**** png file.
As to solve this, goto android/app/src/main/res folder and delete all drawable-** folder only left mipmap-** and values. Also temporarily, please back up deleted folder for IN CASE.

in android/build.gradle, setting like below.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27     //do this in android/app/build.gradle too
                buildToolsVersion '27.0.3'  //do this in android/app/build.gradle too
            }
        }
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        //maven {
        //    url 'https://maven.google.com'
        //}
        google()
    }
}
@pkhien95

This comment has been minimized.

Copy link

pkhien95 commented Jun 1, 2018

@kkusanagi Thanks. This is my solution for the latest version of react-native-camera (1.1.4):

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
    afterEvaluate {
        android {
            compileSdkVersion 27
            buildToolsVersion "27.0.3"

            defaultConfig {
                targetSdkVersion 27
            }
        }
    }
}
@matt-goingout

This comment has been minimized.

Copy link

matt-goingout commented Jun 8, 2018

In my case, none of the above worked, nor was necessary.....

aapt in build tools 23 is a 32bit binary... I'm on a 64 bit system. I didn't have correct 32 bit libs installed so it didn't run.

Installing libncurses5:i386, libstdc++6:i386 and zlib1g:i386 fixed it.

@guguji5

This comment has been minimized.

Copy link

guguji5 commented Jun 24, 2018

@pkhien95 Your solution works for me, thank you for saving my day.

@Scimanyd

This comment has been minimized.

Copy link

Scimanyd commented Jun 29, 2018

in android/gradle.properties, setting like below.
android.enableAapt2=false

@minhphung210

This comment has been minimized.

Copy link

minhphung210 commented Jul 3, 2018

@Scimanyd your solution work for me . thank for that

@kelset kelset added 🔷Android and removed 🔷Linux labels Jul 18, 2018

@CasDigital

This comment has been minimized.

Copy link

CasDigital commented Jul 20, 2018

@Scimanyd Thanks bro, your solution worked, but what exactly does it do though.

@glauberkyves

This comment has been minimized.

Copy link

glauberkyves commented Jul 24, 2018

@matt-goingout you are genious, vlws!!! nince

@viv3kk

This comment has been minimized.

Copy link

viv3kk commented Jul 25, 2018

@matt-goingout

In my case, none of the above worked, nor was necessary.....

aapt in build tools 23 is a 32bit binary... I'm on a 64 bit system. I didn't have correct 32 bit libs installed so it didn't run.

Installing libncurses5:i386, libstdc++6:i386 and zlib1g:i386 fixed it.

where and how to install these libraries?

@glauberkyves

This comment has been minimized.

Copy link

glauberkyves commented Jul 25, 2018

@viv3kk just run sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 in ubuntu

@noahtallen

This comment has been minimized.

Copy link

noahtallen commented Jul 25, 2018

@Scimanyd I feel like it's worth noting that

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.

It seems that this will not be a viable option in the long run.

@kkusanagi

This comment has been minimized.

Copy link

kkusanagi commented Jul 26, 2018

"apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 in ubuntu"

How about MacOS? how to install it?

@erez-guesty

This comment has been minimized.

Copy link

erez-guesty commented Jul 30, 2018

@pkhien95
i'm also run into the same error, tried your solution, and got this error:

Execution failed for task ':app:preReleaseBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (27.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

How does your android/build.gradle and android/app/build.gradle looks like?

@2vm

This comment has been minimized.

Copy link

2vm commented Aug 8, 2018

Hey, guys.

I've also got the same issue after upgrade from RN 0.55 to 0.56, then I added this to my android/build.gradle, and it helped me to generate .apk, but this .apk doesn't work! It just shows the launch screen and then stops...
Does anyone has an idea?

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
    afterEvaluate {
        android {
            compileSdkVersion 27
            buildToolsVersion "27.0.3"

            defaultConfig {
                targetSdkVersion 27
            }
        }
    }
}
@ZeroCool00

This comment has been minimized.

Copy link

ZeroCool00 commented Aug 21, 2018

For those who are doing this before generating apk

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

it generate unnecessary drawable images in drawable folder. so make sure to remove it and try again.

android-> app -> src -> main -> res -> drawable

@devanshujain95

This comment has been minimized.

Copy link

devanshujain95 commented Sep 11, 2018

After trying all the above solutions, facing the same issue. A bit digging into the matter and the workaround to build release apk is:
Delete your android dir in your root folder.

react-native upgrade to build the android dir again

Now generate the release apk by command line

@antonsivogrivov

This comment has been minimized.

Copy link

antonsivogrivov commented Sep 25, 2018

I have the same issue after moving to react-native 0.57

android.enableAapt2=false didn't help me.

@alacret

This comment has been minimized.

Copy link

alacret commented Sep 29, 2018

@antonsivogrivov

This comment has been minimized.

Copy link

antonsivogrivov commented Sep 29, 2018

My solution that helps me with 0.57 react-native

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}
@alacret

This comment has been minimized.

Copy link

alacret commented Sep 29, 2018

@abbasmoosavi

This comment has been minimized.

Copy link

abbasmoosavi commented Oct 21, 2018

So you have to change the code for:

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion '27.0.3'
            }
        }
    }
  }
}

Worked for me! Thanks My bro

@darshancreed

This comment has been minimized.

Copy link

darshancreed commented Oct 25, 2018

@rodrigofbm thanks dude it worked for me

@atdparvaiz

This comment has been minimized.

Copy link

atdparvaiz commented Oct 26, 2018

@antonsivogrivov thanks it worked for me

@karpinski1994

This comment has been minimized.

Copy link

karpinski1994 commented Nov 1, 2018

So you have to change the code for:

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion '27.0.3'
            }
        }
    }
  }
}

Worked for me! Thanks My bro

struggling with same issue now and nothing works ;/

@KangYoosam

This comment has been minimized.

Copy link

KangYoosam commented Nov 4, 2018

#19239 (comment)
this worked for me. version 0.57

@numez

This comment has been minimized.

Copy link

numez commented Nov 15, 2018

My solution that helps me with 0.57 react-native

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

this worked for me. version 0.57 👍

@AmeliaZielinska

This comment has been minimized.

Copy link

AmeliaZielinska commented Nov 27, 2018

@kkusanagi Thanks. This is my solution for the latest version of react-native-camera (1.1.4):

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
    afterEvaluate {
        android {
            compileSdkVersion 27
            buildToolsVersion "27.0.3"

            defaultConfig {
                targetSdkVersion 27
            }
        }
    }
}

If someone is facing this bug using react-native-image-resizer, this solution fixes it!

@Y-JH

This comment has been minimized.

Copy link

Y-JH commented Dec 4, 2018

worked for me ! thank you @Scimanyd

@Y-JH

This comment has been minimized.

Copy link

Y-JH commented Dec 4, 2018

This is my solution 👍
gradle.properties >>
android.enableAapt2=false

project-->>build.gradle>>
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.0.2"
}
}

 afterEvaluate {
         android {
             compileSdkVersion 26
             buildToolsVersion "26.0.2"

             defaultConfig {
                 targetSdkVersion 26
             }
         }
     }

}
}

@Lady-Gao

This comment has been minimized.

Copy link

Lady-Gao commented Dec 10, 2018

在转向react-native 0.57之后,我遇到了同样的问题

android.enableAapt2 = false没有帮助我。

解决了吗?

@RuthenicEye

This comment has been minimized.

Copy link

RuthenicEye commented Dec 11, 2018

I had the same issue, @rodrigofbm 's solution worked for me.
Just add the following at the end of ../android/build.gradle file

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.0.2"
        }
     }
  }
}

ysam12345 added a commit to ysam12345/ActivityMaster-MobileClient that referenced this issue Dec 11, 2018

@edisonlao

This comment has been minimized.

Copy link

edisonlao commented Dec 14, 2018

Hey, guys.

I've also got the same issue after upgrade from RN 0.55 to 0.56, then I added this to my android/build.gradle, and it helped me to generate .apk, but this .apk doesn't work! It just shows the launch screen and then stops...
Does anyone has an idea?

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
    afterEvaluate {
        android {
            compileSdkVersion 27
            buildToolsVersion "27.0.3"

            defaultConfig {
                targetSdkVersion 27
            }
        }
    }
}

I have the same problem, but i have no idea,did you solved it?

@Mohsen322

This comment has been minimized.

Copy link

Mohsen322 commented Dec 22, 2018

So you have to change the code for:

subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion '27.0.3'
            }
        }
    }
  }
}

work for me like a boss! thank for saving time

@vivek-walecha-657

This comment has been minimized.

Copy link

vivek-walecha-657 commented Dec 24, 2018

@antonsivogrivov where should i add this:
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
}
}

@rip3rs

This comment has been minimized.

Copy link

rip3rs commented Jan 2, 2019

@vivek-walecha-657 in <ROOT>/android/build.gradle

if you are on 0.57 ++ I would recommend using @antonsivogrivov solution. as it has the variables defined from RN.

My solution that helps me with 0.57 react-native

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}
@trandangtri

This comment has been minimized.

Copy link

trandangtri commented Jan 11, 2019

My solution that helps me with 0.57 react-native

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

You saved my day. Thanks alot.

@Abhishekgarg727

This comment has been minimized.

Copy link

Abhishekgarg727 commented Jan 14, 2019

Here is my Gist with my sample project bulid.gradle , package.json using react native 55.4

https://gist.github.com/Abhishekgarg727/daf031fb9f94fdfd985e84db57dedbe1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment