Tag Archives: react native

[Solved] CommandWithNoStdoutInvokationFailure Unable to start ADB server.

Error: CommandWithNoStdoutInvokationFailure: Unable to start ADB server. Please make sure the Android SDK is installed and is properly configured in the Editor
Error:

CommandWithNoStdoutInvokationFailure: Unable to start ADB server. Please make sure the Android SDK is installed and is properly configured in the Editor. See the Console for more details.
UnityEditor.Android.Command.RunWithShellExecute (System.String command, System.String args, System.String workingdir, System.String errorMsg) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.ADB.StartServer () (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.ADB.Run (System.String[] command, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.AndroidDeploymentTargetsExtension.GetKnownTargets (UnityEditor.DeploymentTargets.IDeploymentTargetsMainThreadContext context, UnityEditor.ProgressHandler progressHandler) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckDevice.GetTargetDevices (UnityEditor.Android.ADB adb) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckDevice.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <61e151d28db74087bf4788498b7351e6>:0)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

 

Solution:

This problem is only applicable to windows, if it is linux or mac, please follow the relevant instructions to use the shell statement to configure in the termination.
If the sdk is installed on Windows, enter cmd in the run, call up the windows command line, enter adb, and the system feedback says that it is not a system command. . . . .
The solution is simple:
Go to the tools directory under the Android sdk directory, find two files, adb.exe and AdbWinApi.dll, select them, copy them, and paste them in the system directory /windows/system32/.
Then enter adb in the command line, the problem is solved!

[Solved] React Native Red screen Error: Unable to load script from assets

If the above error occurs, first confirm whether the RN service runs successfully

In some cases, the startup fails, or it is shut down unexpectedly after startup, or the ports are inconsistent.

Another situation is recorded here:

If it is a project from the new cluster on GitHub, the directory of Android\app\SRC\main\assets may be empty (the assets folder needs to be created). At this time, it needs to be run under the terminal of the project root directory:

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ 

To create the missing file

After running, you will see the missing index on the red screen android. Bundle file.

Run it again and the problem is solved.

Registry key Error: Java version has value ‘1.8‘, but ‘1.7‘ is required

Registry key Error: Java version has value ‘1.8’, but ‘1.7’ is required

Problem Description:

1. Jdk1.7.0 is installed first_ After 80, jdk1.8.0 was installed_ 181. The former is configured in the environment variable
2. The following error occurs when entering Java – version in CMD:

Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.7', but '1.8' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

Problem solving:

When upgrading from jdk1.7 to JDK1.8, there are three things to confirm:

1. System environment variables

2. Registry

Computer \ HKEY_ LOCAL_ MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

3. Update java.exe javaw.exe javaws.exe under C: \ windows \ system32

Error caused by too many versions of JDK installed on the computer

For example, there was no problem installing 1.7

After installing 1.8 and modifying the environment variables, the java.exe javaw.exe javaws.exe under C: \ windows \ system32 is still in the 1.7 installation package.

Just replace the java.exe of 1.7 with Java 1.8.

React-native Error: Make sure you have the Android development environment set up [Solved]

The error message is as follows

Run gradlew tasks to get a list of available tasks. 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.

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

Error source: my RN code from the company’s computer clone is normal, and the above errors occur in yarn install and yarn Android, both in virtual machine running and real machine running. In order to try and error, I init a project again, and the result is such an error, but I can still run individual RN projects, of course.

Consult the document solution 1:
just start it directly with Android studio and let Android studio automatically integrate some Android environments and then run applications. However, I personally gave up because I was not very proficient in as running Android, but I thought it would be troublesome if I needed to run as every time I created an RN project

Solution 2:
the blogger said that it is necessary to configure the ADB environment. After a review, it is found that almost all the configured Android environments have been configured

%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\emulator
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin

Document review solution 3:

Place the following line in your Android/gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

What do bloggers mean when they post the above sentence?In fact, the support community is messy. Google launched Android X and gradually shifted its focus and migrated, so our project depends on the package and needs to be migrated
Android. Useandroidx = true indicates that androidx is enabled for the current project. Android. Enablejetifier = true indicates that dependent packages will also be migrated to androidx. If the value is false, it means that the dependent package will not be migrated, but there may be problems when using the content in the dependent package. Of course, if no three-party dependency is used in my project, this item can be set to false
in fact, these two pieces of code were already there when we created the RN project

Solution 4 (feasible):
in fact, I just saw that the blogger posted several strings of English, one of which was

# npx react-native doctor

I knew that the NPX react native doctor command should be similar to the fluent doctor command. Check whether the current running environment meets the requirements

So I ran the command on the command line. I found that the doctor told me that I lacked the java8 environment (in fact, I do have it, but he said that I must lack it) and Android tools 29.2. So I uninstalled java8, reinstalled and reconfigured Java_ Home go to as to download 29.2
just come back and check it again

react Error: Unable to resolve module mobx-react

Mobx needs to be used in the development process. After installing and running according to the instructions on the official website, an error is always reported: error: unable to resolve module mobx react from E: (uploadcode, update, test, app, app. JS: mobx react could not be found within the project or in these directions:
node_ modules
…\ node_ Modules
at the beginning, I thought that the network was not good when I downloaded it. I didn’t download it completely, so I uninstalled what I just installed and installed it again, but there was still this error finally, I can only look at the error information to see if there is a solution. Finally, this sentence attracted my attention: mobx react could not be found within the project or in these directions:
node_ modules
…\ node_ modules

On node_ Modules and_ I can’t find mobx react in the modules folder, so I went into these two folders and found that… – node_ Modules folder contains the content I just downloaded, but node_ There is no module, so I enter the node from the terminal_ In the modules folder, download and install the dependency again
after downloading, rerun the project and no error will be reported
summary: if there is no dependency for you to download in any folder, go to the corresponding folder and download it again, so that all the folders mentioned in the error message have the dependency for you to download

React native android: How to Upload Formdata

  let resizedImage = file // file
  let formData = new FormData();
  let name = `xxxx.jpeg`;
  let file = { uri: "file:///" + resizedImage.path.split("file:/").join(""), type: 'image/png', name: escape(resizedImage.name), fileType: 'image/\*' };   //The key here (uri and type and name) cannot be changed,
  formData.append("file", file); //the files here are the key needed by the backend
  formData.append("token", token); //the files here are the key needed by the backend
  formData.append("key", Math.random()+'__'+name); //the files here are the keys needed by the backend
                       

The problem of mobile hybrid development RN Android deployment appears Unsupported class file major version xx

  General error during semantic analysis: Unsupported class file major version 57
  
  java.lang.IllegalArgumentException: Unsupported class file major version 57
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:184)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:152)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:273)

Appear this error is your JDK version is wrong, general RN ask JDK version is 1.8, recommends after installation, the project of the android/gradle. Add the following configuration properties
org. Gradle. Java. Home =/Volumes/Mac/Software/android \ Studio app/Contents/jre/JDK/Contents/home

React Native: TypeError: Network request failed

It’s been about four weeks since I started react Native’s project, and it’s about the packaging stage. However, I found that the App on the iOS side was working normally. Android apps are slow to update data.
Post my request interface

let NetUtil = {
    postJson(type, data){
        return new Promise(function (resolve, reject) {
            fetch("http://www.samplesite.com",{
                method: 'POST',
                headers: {
                    "Accept": "application/json",
                    "Content-Type": 'application/json',
                    "type":"getUserData"
                },
                body: JSON.stringify(data)
            }).then((response) => {
                if (response.ok) {
                    return response.json();
                } else {
                    reject({status:response.status})
                }
            }).then((response) => {
                resolve(response);
            }).catch((error) => {
                console.log(error);
            }).done();
        })
    },
}

In a nutshell, use fetch to send JSON data to the server via a POST request.
Use the Google browser to debug and make requests
At the end of an android: first success, second failure. Success on the third shot, failure on the fourth…
On iOS: Everything is fine.
The request failed as follows:
TypeError: Network request failed:
 
At the XMLHttpRequest. XHR. Onerror (fetch. Js: 441)
At the XMLHttpRequest. DispatchEvent (event – target. Js: 172)
At the XMLHttpRequest. SetReadyState (XMLHttpRequest. Js: 567)
At the XMLHttpRequest. __didCompleteResponse (XMLHttpRequest. Js: 397)
the at XMLHttpRequest. Js: 503
the at RCTDeviceEventEmitter. Emit (EventEmitter. Js: 179)
the at Messagequeue. ___ callfunction (messagequeue. js:351)
at messagequeue. js:116
at messagequeu. ___ (messagequeue. js:314)
at MessageQueue. CallFunctionReturnFlushedQueue (MessageQueue. Js: 115)
 
 
I was initially skeptical that it was a network framework problem, so I tried XMLHttpRequest, Axios… Without exception. Each time on the androidend the first attempt succeeds and the second attempt fails. Fetch and Axios are both XMLHttprequest-based encapsulations.
 
 
On StackOverflow and Github, someone also proposed sending with FETCH and got TypeErrpr:Network Request failed. I’ve seen almost everything. To summarize their various answers:
If you want to obtain data from the server set up locally on your computer by simulating it through HTTP request, you need to change localhost to the real IP of your computer. If you send an HTTP request from a remote server to get the data, there is basically no solution. One person asked that he solved the problem by demoting RN. Android SDK version issues. Nginx configuration issues…
https://stackoverflow.com/questions/33969333/react-native-fetch-request-failed-with-error-typeerror-network-request-faile
https://stackoverflow.com/questions/38077273/react-native-fetch-network-request-failed-not-using-localhost
https://stackoverflow.com/questions/38418998/react-native-fetch-network-request-failed
https://github.com/facebook/react-native/issues/10404
I’ve tried to downgrade React Native, and I’ve tested the Android SDK through 23 to 26. But it didn’t work. It didn’t solve the problem.
Then I began to wonder if there was a problem with the interface.
I bought several API interfaces online, both post and GET. Tests have found no success or failure in the android end of the request issue. Which means it has nothing to do with react Native or Android versions. The problem is the interface. But what I can’t explain is that there’s not a single success or failure on iOS. I haven’t had any problems testing interfaces in Python.
“– June 30, 2018
Http1.1 defaults to long connections. Almost all browsers and Ajax default to “Connection”:” keep-alive “in the header. The default for iOS is “Connection”:” Close “.
I’m going to change the request header to

             headers: {
		"Accept": "application/json",
		"Content-Type": 'application/json',   
		"Connection": "close",   
		"type": "getUserData",   
                },"Connection": "close",   
		"type": "getUserData",   
                },

My problem is solved by the above methods.
 
 

TypeError:Network request failed

recently run react native project application in which the data is the local json of the request before good suddenly reported TypeError:Network request failed

The inside of the

project request address localhost is written into computers at the real IP is ok

before modification :

modified:

view computer IP address method :

Windows: open the command window to execute ipconfig

MAC: open a command window to execute ifconfig

Error failed to build IOS project. We ran “xcodebuild” command but it exited wit

did not change the profile file before NPM run ios is no error. After changing the profile to introduce react and using pod install, the error report is as follows:

error Failed to build iOS project. We ran “xcodebuild” command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app

solution

1. Delete the item dependent package and the yarn cache

rm -rf node_modules & & yarn cache clean

2. Repackage

yarn install

3. Clear React-Native cache

rm -rf ~/.rncache

New folder .rncache

mkdir ~/.rncache

5. Directly run the download script

node_modules/react-native/scripts/ios-install-third-party.sh

6. If the download is completed, run react-native run-ios directly to succeed

7. If the download fails, run the code in 4 repeatedly for more than 20 times before I succeed, or do the following steps

8. The four download links are key, use the tool to download these four files. download link is closely related to React-Native version, please check the file version carefully.

(1) https://github.com/google/glog/archive/v0.3.5.tar.gz

(2) https://github.com/google/double-conversion/archive/v1.1.6.tar.gz

(3) https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz

(4) https://github.com/facebook/folly/archive/v2018.10.22.00.tar.gz

page open the link to download

9. After downloading, enter directory

open ~ /. Rncache

10. Move the four downloaded files to the directory

11. Run the installation script again, because you are using the local download file, all run quickly

node_modules/react-native/scripts/ios-install-third-party.sh

12. If not successful, continue running node_modules/react-native/scripts/ ix-install – thirdparty. sh until successful

13. The project can run, the first start will be a little slow, patience will wait on the line

react-native run-ios