Issue
I'm a new in react native so first thing I made is to install react native by running
npm install -g react-native-cli
and after running react-native info
I get this
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
after that I create a new project with webstorm from here [https://www.jetbrains.com/help/webstorm/react-native.html ] after that I launch the emulator with 19 API level and then I run the App.js file and I get this
"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 }
the error as showing in the log Is about the adb but I can use the adb command to install and get logcat in both the emulator and the real devices without any error
after searching on the internet I tried to run this two commands
adb reconnect
adb reverse tcp:8081 tcp:8081
but I get the same error as following
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
the code that I run is the default one that is created by react native also the app is installed successfully on my emulator but when I run it I get an error tells me the app will stop also I noted when I launch the emulator it's gives me this error
Solution
In React-Native documentation, it is mentioned that it is better to remove react-native-cli because it is causing some issues.
I had the same problem, and it is solved when I changed the API of the emulator from 19 to 29. So, the problem is the API version. But Also make sure that you run >npm install.
Also, I used genymotion for the emulator, I suggest that you use it, and open the emulator. and open two terminals, in the first one type >react-native start and in another terminal type >npx react-native run-android. Moreover, make sure that you don't have any problem with the port.
Hope this helps.
Answered By - Judy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.