yesIamFaded
yesIamFaded

Reputation: 2068

Android Studio React Native Build fails

I took the project I am developing at my workplace home and wanted to run it here on my machine.

I got many many errors which I fixed, but there are some that I don't know how. Maybe you guys know a fix.

\android\app\build\intermediates\external_file_lib_dex_archives\debug\out

this output get generated when building the project from AS.

I read that the fix is to add this: android.enableBuildCache=false to gradle.properties but when I do that I get this error which make 0 sense tbh.

: Cannot parse project property android.enableBuildCache='false ' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.

EDIT: Ok there was an empty space after false hence the second error but even with that corrected I get the first error.

Running it from vsCode gives me: Execution failed for task ':app:processDebugResources'.

EDIT2: Newest Error in AS:

> Task :app:mergeExtDexDebug
java.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out
    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:80)
    at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:522)
    at java.nio.file.Files.newDirectoryStream(Files.java:457)
    at java.nio.file.Files.list(Files.java:3451)
    at com.android.build.gradle.internal.tasks.DexMergingParams.getAllDexFiles(DexMergingTask.kt:502)
    at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:423)
    at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
    at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:50)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
    at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:53)
    at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:217)
    at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:212)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    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:56)
    at java.lang.Thread.run(Thread.java:748)


> Task :app:transformClassesWithDexBuilderForDebug
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug
> Task :app:mergeDebugJavaResource
> Task :app:mergeExtDexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > java.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 19s
150 actionable tasks: 147 executed, 3 up-to-date

Upvotes: 5

Views: 5930

Answers (5)

Amin Azizzadeh
Amin Azizzadeh

Reputation: 500

You can solve this issue by deleting the .gradle folder from "NameOfProject/android" and again running Android-Studio, I hoped this is solved. :))

Upvotes: 0

salvi shahzad
salvi shahzad

Reputation: 1261

Try this command in your project root:

cd android && rm -rf .gradle && rm -rf .idea

and then

./gradlew clean

and then build again, works like a charm.

Upvotes: 1

nithinpp
nithinpp

Reputation: 2025

As Murat Kızılöz suggested, you can get around this by adding multiDexEnabled truein the android/app/build.gradle file.

This is because Android system has a 64K reference limit

In Android, the compilers convert your source code into DEX files. This DEX file 
contains the compiled code used to run the app. But there is a limitation with the
DEX file. The DEX file limits the total number of methods that can be referenced
within a single DEX file to 64K i.e. 65,536 methods. So, you cant use more than
64K methods in a particular DEX file. These 64K methods include Android framework
methods, library methods, and methods in our code also. This limit of 64K is
referred to as the "64K reference limit".

So, if our app exceeds 65,536 methods, we will encounter a build error that indicates our app has reached the limit of the Android build architecture.

To get around this, you can manually enable this in the app build.gradle file

You can read more about this at Android Multidex

Upvotes: 2

werfar
werfar

Reputation: 121

Try to delete the .gradle folder from projectname/android - folder and rebuild. Solved it for me.

Upvotes: 11

Murat Kızıl&#246;z
Murat Kızıl&#246;z

Reputation: 95

I have encountered a similar error before. As a result of my research as a solution

In the android/app/build.gradle file multiDexEnabled true

android {
    defaultConfig {
        ...
        targetSdkVersion 28
        multiDexEnabled true // here
    }
    ...
}

Upvotes: 4

Related Questions