Javascript adb.exe:错误:运行react本机应用程序时关闭
我是react native的新手,所以我做的第一件事就是通过运行Javascript adb.exe:错误:运行react本机应用程序时关闭,javascript,android,react-native,adb,webstorm,Javascript,Android,React Native,Adb,Webstorm,我是react native的新手,所以我做的第一件事就是通过运行 npm安装-g react native cli 运行react native info 我明白了 C:\Users\husam\WebstormProjects\calculator>react-native info info Fetching system and libraries information... System: OS: Windows 10 10.0.18363 CPU: (4) x
npm安装-g react native cli
运行react native info
我明白了
C:\Users\husam\WebstormProjects\calculator>react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18363
CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz
Memory: 815.06 MB / 3.92 GB
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 7, 8, 9
Build Tools: 19.1.0, 28.0.3, 29.0.3
System Images: android-19 | Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6308749
Languages:
Java: 1.8.0_231
Python: 3.7.6
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
之后,我从这里用webstorm创建了一个新项目
[
]
之后,我启动了具有19个API级别的仿真器
然后我运行App.js文件,得到这个
"C:\Program Files\nodejs\node.exe" C:\Users\husam\AppData\Roaming\npm\node_modules\react-native-cli run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Task :app:generatePackageList
> Task :app:preBuild
> Task :app:preDebugBuild
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:bundleDebugJsAndAssets SKIPPED
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders UP-TO-DATE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:copyDebugBundledJs SKIPPED
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:mergeDebugJavaResource UP-TO-DATE
> Task :app:checkDebugDuplicateClasses UP-TO-DATE
> Task :app:desugarDebugFileDependencies UP-TO-DATE
> Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug UP-TO-DATE
> Task :app:mergeExtDexDebug UP-TO-DATE
> Task :app:mergeDexDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :app:mergeDebugNativeLibs UP-TO-DATE
> Task :app:stripDebugDebugSymbols UP-TO-DATE
> Task :app:packageDebug UP-TO-DATE
> Task :app:installDebug
10:21:40 V/ddms: execute: running am get-config
10:21:45 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
10:21:45 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'MY_phone(AVD) - 4.4.2' for app:debug
10:21:45 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
10:21:45 D/Device: Uploading file onto device 'emulator-5554'
10:21:45 D/ddms: Reading file permision of C:\Users\husam\WebstormProjects\calculator\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
10:21:49 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
10:22:25 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:22:25 V/ddms: execute: returning
10:22:25 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
10:22:26 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:22:26 V/ddms: execute: returning
Installed on 1 device.
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 SUCCESSFUL in 4m 49s
27 actionable tasks: 2 executed, 25 up-to-date
info Connecting to the development server...
adb.exe: error: closed
info Starting the app on "emulator-5554"...
warn Failed to connect to development server using "adb reverse": Command failed: C:\Users\husam\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.calculator/.MainActivity }
日志中显示的错误与adb有关,但我可以使用adb命令在模拟器和真实设备中安装并获取logcat,而不会出现任何错误
在互联网上搜索后,我尝试运行这两个命令
adb重新连接
adb反向tcp:8081 tcp:8081
但我得到的错误与下面的相同
C:\Users\husam\WebstormProjects\calculator>adb reconnect
reconnecting 4203605bb24a3200 [device]
C:\Users\husam\WebstormProjects\calculator>adb reverse tcp:8081 tcp:8081
adb.exe: error: closed
我运行的代码是由react native创建的默认代码
此外,该应用程序已成功安装在我的模拟器上,但当我运行它时,我得到
一个错误告诉我应用程序将停止
我还注意到,当我启动模拟器时,它会给我这个错误
在React Native文档中,提到最好删除React Native cli,因为它会导致一些问题 我也遇到了同样的问题,当我将模拟器的API从19更改为29时,问题就解决了。因此,问题在于API版本。 但也要确保运行>npm安装 另外,我使用genymotion作为模拟器,我建议您使用它,然后打开模拟器。并打开两个端子,第一个端子类型>反应本机启动 在另一个终端类型中,npx react原生运行android。此外,请确保端口没有任何问题
希望这能有所帮助。是的,API级别是问题所在,而且我发现对我来说最低级别是22