Android Studio React原生构建失败

nszi6y05  于 2023-02-09  发布在  React
关注(0)|答案(5)|浏览(186)

我把我正在开发的项目在我的工作场所的家,并希望运行它在这里对我的机器。
我修正了很多错误,但是有些我不知道怎么修正,也许你们知道怎么修正。

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

此输出在从AS构建项目时生成。
我读到的解决办法是添加以下内容:android.enableBuildCache=false到gradle.properties,但是当我这样做的时候,我得到了这个错误,这是没有意义的。
Cannot parse project property android.enableBuildCache='false ' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.
编辑:好的,在false之后有一个空格,因此是第二个错误,但即使纠正了这个错误,我还是得到了第一个错误。
从vsCode运行它可以得到:Execution failed for task ':app:processDebugResources'.
EDIT2: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
vq8itlhq

vq8itlhq1#

我以前也遇到过类似的错误。由于我的研究作为解决方案
android/app/build.gradle文件multiDexEnabled true

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

ws51t4hk2#

正如Murat Kızılöz所建议的,可以通过在android/app/build.gradle文件中添加multiDexEnabled true来解决这个问题。
这是因为Android系统有64K的参考限制

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

因此,如果我们的应用超过65,536个方法,我们将遇到构建错误,表明我们的应用已达到Android构建架构的限制。
要解决此问题,您可以在app build.gradle文件中手动启用此功能
您可以在Android Multidex上了解更多信息

s3fp2yjn

s3fp2yjn3#

在项目根目录中尝试以下命令:

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

然后

./gradlew clean

然后重新建造,就像一个魅力。

fivyi3re

fivyi3re4#

您可以通过从“NameOfProject/android”中删除.gradle文件夹并再次运行Android-Studio来解决此问题,我希望此问题得到解决。:))

zysjyyx4

zysjyyx45#

尝试从projectname/android - folder中删除.gradle文件夹并重新构建。

相关问题