Skip to main content

React-Native 编译 Android 应用报错

· One min read
Chengzihan

:app:installDebug

问题描述

* What went wrong:
Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing 'install':
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

最关键的一句:

Requested internal only, but not enough space

即:

申请的内部空间不足

解决方案

扩充模拟器空间。

1

在模拟器的设置中,将内部存储空间扩充到 4096M 即可。

访问错误

问题描述

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

无法正确访问仓库安装依赖。

解决方案

android 目录下的 build.gradle 文件中,将 android/build.gradle 中的 jcenter() 和 google() 分别替换为 maven { url 'https://maven.aliyun.com/repository/jcenter' }maven { url 'https://maven.aliyun.com/repository/google' }(注意有多处需要替换)。