在设备上运行React Native时出现问题

时间:2020-07-16 00:05:21

标签: android reactjs react-native android-studio npx

我试图在我的Android手机上运行React Native项目,当我运行'npx react-native run-android'时,这给了我这个问题。但是,如果我使用Android Studio模拟器,它就可以正常工作:

08:57:53 V/ddms: execute: running am get-config
08:57:53 V/ddms: execute 'am get-config' on '2b704600a21c7ece' : EOF hit. Read: -1
08:57:53 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'SM-G9650 - 10' for app:debug
08:57:53 D/app-debug.apk: Uploading app-debug.apk onto device '2b704600a21c7ece'
08:57:53 D/Device: Uploading file onto device '2b704600a21c7ece'
08:57:53 D/ddms: Reading file permision of /home/thadeucesario/Documents/Thadeu/Code/ReactNative/mobile/android/app/build/outputs/apk/debug/app-debug.apk as: rw-rw-r--
08:57:54 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
08:57:57 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on '2b704600a21c7ece' : EOF hit. Read: -1
08:57:57 V/ddms: execute: returning

> Task :app:installDebug FAILED

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.2/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 2 executed, 25 up-to-date
Unable to install /home/thadeucesario/Documents/Thadeu/Code/ReactNative/mobile/android/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:562)
at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2700)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1061)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:26690)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5433)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:5012)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
Caused by: java.io.IOException: Requested internal only, but not enough space
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:531)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:447)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:462)
at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:742)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:560)
... 11 more

有人可以帮我吗?

谢谢

2 个答案:

答案 0 :(得分:2)

在终端Caused by: java.io.IOException: Requested internal only, but not enough space的最后六行。当您的物理设备中没有足够的空间来安装和运行应用程序时,基本上会发生这种情况。

确保在打开调试器的情况下打开开发人员模式,并且物理android设备上还有足够的空间。 尝试使用adb devices检查所有连接的设备(如果没有,必须首先安装adb)。 然后强行关闭模拟器,或者关闭Windows或Linux模拟器。

然后运行npx react-native run-android

我认为这将非常适合您。

答案 1 :(得分:1)

尝试使用Android Studio打开android路径并使用它进行构建,可能控制台会显示错误在哪里。

使用Android Studio,您还可以转到:

File > Ivalidate Caches/Restart...

然后单击“无效并重新启动”。之后,请尝试使用以下命令再次运行您的项目:

npx react-native run-android