I am using ViroARSampleApp code to demonstrates placing, rotating and dragging objects in AR. Everything is working fine when I run react-native run-android --variant=arDebug but when I detach data cable and run the app then the application is running fine but objects are not rendered.
I tried to make proper APK file and install to the device but facing the same issue. I tried these commands to make build react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/, cd android, ./gradlew assemblearDebug. i also tried ./gradlew bundlearDebugJsAndAssets.
I am new in react native and AR, kindly suggest me the solution for this issue.
try this
./gradlew assembleGvrRelease
I was getting one error :
Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release
So I have fired this command :
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
So that error gone, but Now problem is I am not able to debugging. If I am using react-native start command then also in not bundling.
So main problem is I am not able to bundle application.
Please guide on this point.
Thanks.
I am getting this error.
Points :
You can still debug on logcat in android studio or Xcode.
run react-native run-android in one terminal and react-native start in another terminal
Please check whether the port is 8081 if not then change it in the dev setting in adb by adding your local pc ip.
Delete node modules and try updating your metro bundle. Then install them. Hope this will work!
Sometimes the metro bundle hangs, its common.
I think title explains itself my problem, on emulator everything works as it should be, when apk builded I have transfered it on my smartphone and there's errors:
https://imgur.com/a/pSEKXHx
I was have the same issue when i assemble Release/Debug apk and install it on my physical smartPhone
Do this commands in your Project Directory :
mkdir android/app/src/main/assets
(if you have the assets folder you will see error like directory is already exist ... no problem! go to next command)
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android or assemble the apk
it should work GOOD LUCK
I have made sure that bundler and emulator are running.
If I use this commend
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
It might work but refresh won't happen when I press rr in emulator.
I have also tried reversal of abd adb reverse tcp:8081 tcp:8081.
Nothing works for me.
click here to see the error screen.
To resolve Unable to load script from assets index.android.bundle - React Native follow below process :
You have to create dir assets manually in your android project or make Directory by Terminal/CMD enter mkdir android/app/src/main/assets
Go at the created Directory if that is successfully created then
run step 3 Command:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
you have your missed files in the folder now you can Run your React Native project npm run android.
Sometimes you have to clear the cache to load your assets properly.
Use the command react-native start --reset-cache
and re-run react-native run-android
I had this issue after having had it work for the past couple days. I realized that I had manually configured a proxy. As soon as I turned that off, it worked.
For me, Gradle clean fixed it when I was having an issue on Android
cd android
./gradlew clean
I'm new in react-native.
I have run react native project on Ubuntu by using 'react-native run-android' command. And I got the error on emulator
"Unable to load script from assets 'index.android.bundle'.Make sure your bundle is packaged correctly or you are running a package server."
I also got this and I resolved this using following commands in your project directory:
$ mkdir android/app/src/main/assets
$ 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
$ react-native run-android
Using
npm version 4.3.0
react-native-cli version 2.01
react-native version 0.49.5
In project directory,
mkdir android/app/src/main/assets
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
The file name has changed from index.android.js to index.js
In my case (embedding React Native as a new Activity into an existing Android Code Base), the problem was Android Studio had auto-imported the wrong BuildConfig.
Wrong:
import com.facebook.react.BuildConfig;
Right:
import com.mywebdomain.myapp.BuildConfig;
This would apply to the wherever you are housing this block of code:
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
For this error :
unable to load script from assets 'index.android.bundle'
1) Check for "assets" folder at :
mkdir android\app\src\main\assets
If the folder is not available, create a folder with name "assets" manually. and execute the Curl command in terminal.
2). Curl command:
curl "http://localhost:8081/index.android.bundle?platform=android" -o"android/app/src/main/assets/index.android.bundle"
It will create the "index.android.bundle" file in assets folder automatically and resolved the issue.
3) Then:
react-native run-android
This helped me resolve the problem in following steps.
If not than (in project directory) mkdir android/app/src/main/assets
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
react-native run-android
Ubuntu
first time, I created new app with react-native init project-name. I got the same error. so i do the following steps to resolve this in my case.
Firstly run sudo chown user-name-of-pc /dev/kvm in my case.
While debugging from your Android phone, select Use USB to Transfer photos (PTP).
Create Folder assets in 'project-name/android/app/src/main'.
make sure index.js be avaiable into your project root directory and then run below command from console after cd project-name directory.
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
or for index.android.js then
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
run command ./studio.sh in android-studio/bin directory. It will opens up Android Studio.
run command react-native run-android.
It seems to be a problem in the newest version of React Native (0.46). Using the previous version seems to solve the problem react-native init name --version react-native#0.45.1 and removes the error when running react-native run-android.
Edit: It is now fixed in version 0.46.1.
In my case the problem was in this row in the React Activity file:
mReactInstanceManager = ReactInstanceManager.builder()
...
.setUseDeveloperSupport(BuildConfig.DEBUG)
...
BuildConfig.DEBUG must be set to true, while in my case it was false
For Windows user only:
Copy the path of adb location and set into PATH in your system variable,
Open project structure and delete node module folder.
Edit your project package.JSON file
change react-native version "react-native": "0.55.2", and
babel "babel-preset-react-native": "4", after that run npm install
Restart cmd and js server and run your react native project by react-native run-android
I was stuck in the same problem for hours and what solved my issue is this :
Create "assets" folder in main directory of project as well as in "newreactproject\android\app\src\main". Then put this script in package.json "android-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android"
like:
"name": "newreactproject",
"version": "0.0.1",
"private": true,
"scripts": {
"android-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
}
I discovered a solution suggested in the thread at https://github.com/facebook/react-native/issues/15388
It is to manually set the Debug server host & port for device setting for the app on the phone.
Step by Step to eject and run a CRNA on Android
In terminal:
create-react-native-app myApp
cd myApp
yarn run eject (I used default options "regular React Native project")
react-native run-android
(now the app should be compiled and installed on the phone)
On phone:
Run the app (expect to see the red error screen! - click Dismiss button in bottom left)
Shake the phone and pick Dev Settings
Pick Debug server host & port for device and set to 192.168.x.x:8081 (make it your actual LAN IP of course)
Restart app on phone and you should see green bar at the top "Loading from 192.168.x.x:8081..."
You should also see some "Bundling index.js" action in the Metro Bundler (that opened when running react-native run-android)
After the bundle is finished, the app should be running on your Android device!
Live Reload (when source files change) also works - just shake the phone and touch "Enable Live Reload"
You can run the project from Android Studio, but you need to first start the Metro Bundler with the command react-native start in the CRNA project root.
I was getting this error too. But adb reverseworked for me
i'm using ubuntu 18.04 LTS ,react-native: 0.55.2. In my case here are few solutions for the problem .
in the terminal before you run npm run android type npm start. you might see an error
ERROR Metro Bundler can't listen on port 8081.
this occurs because there might be a process which is already running
Solution- type sudo lsof -i :8081
you will see an output similar to this
**COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 5670 tasif 17u IPv6 80997 0t0 TCP *:tproxy (LISTEN)**
type kill -9 (PID number)then run npm android.
if it still doesnt work type again npm start . you might see this error
ERROR ENOSPC: no space left on device, watch'....../......./.....'
solution :
$ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p
then type npm run android.
please go to this link to see different solutions and more details https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details
delete the emulator and build it again. kill the recent terminal and then build emulator and start again.