I'm currently struggling a bit with react native.
What I want to have is a library project based on react native which I can then include in some of my apps.
First thing I tried was to move all the basic react setup code [1] into a Fragment inside an existing app. This worked without any problems.
Then I started a completely new Android project with an empty Activity.
Into this project I added a new Android Library project module which should contain the "react native fragment". I initialised the react native project in my root project folder then.
My current project structure looks like this:
ReactApplication
- basic files (index.android.js, index.ios.js, package.json, build.gradle, settings.gradle)
- app/ (contains the real native android app which includes the "react native fragment")
- reactlib/ (library project which contains a fragment with the code from [1])
- ios/
- node_modules/ (contains react-native)
Starting the dev-server via npm start works without any problems but as soon as I start the Android app I get the folowwing logcat outputs:
W/unknown:React(26957): Unable to dispatch keyboard events in JS as the react instance has not been attached
W/unknown:React(26957): You seem to be running on device. Run 'adb reverse tcp:8081 tcp:8081' to forward the debug server's port to the device.
E/(26957): Unable to load script from assets: index.android.bundle
E/ReactNative(26957): Got JS Exception: ReferenceError: Can't find variable: require
Please note that I did the adb reverse tcp:8081 tcp:8081 thing and the error is still showing up.
Later I want to create an aar out of the Android Library project and access it via maven.
What am I doing wrong? Or is what I want to do simply not possible?
[1] https://facebook.github.io/react-native/docs/embedded-app-android.html#add-native-code
After debugging and trying out couple of things, i figured that it fails to load the bundle file from server when bundled in aar.
If you add index.android.bundle in android assets folder, it starts working.
Related
I am currently using React Native 0.55.2 for my project and I am trying to integrate the React Native Navigation from wix into my native projects (both ios and android). I followed their instructions in the website and successfully set it up for ios (it was able to build and run successfully in the emulator). I was also successful in building it for android (see image, I used npm run android), however, when I run it on the android emulator, the image below pops up. I don't know why it tries to look for android.index.js even if my react native project is setup for the latest one which only needs 1 index file which is index.js
Build Success (npm run android):
Android Emulator Error:
Not sure my answer can resolve your problem but normally if I hit this error, I will follow below step:
Clear cache
Close the terminal and uninstall my app, simulator
Delete folder node_module and run yarn again (optional)
Run react-native run-android
my version: 55.4
Check the Java files of the android project, like Main Application.java or MainActivity.java. They contain a method that returns the bundle file name and you'll see it contains 'index.android' instead of 'index'.
You should be able to find this place easily also by using 'git grep'.
Trying to create blank project with ionic2 not ionic1 or ionic3 using the below command in terminal
ionic start SqliteDemo blank --type ionic2
Error comes as below:
✔ Creating directory ./SqliteDemo - done!
✖ Looking up starter - failed!
[ERROR] Unable to find starter template for blank
If this is not a typo, please make sure it is a valid starter template
within the starters repo: https://github.com/ionic-team/starters
what i have tried ?
ionic start SQliteDemo blank --v2
not worked
all above commands just create Folder for the given name and nothing is inside.
Actually Trying:
I need to work with sqlite storage/ with any android native api's, as first attempt i try to do a sample project based on sqlite so that i can add android platform to this project and open with Android-Studio and check whether the .db file is created and working or not using Android-Monitor. If any references for this question will be very much appreciated.
"Cannot find entry file index.android.js in any of the roots:
[/"c:////Users////Sekf////Documents////GitHub////TestProjOne/"]"
I started a react native project from scratch using react-native init ProjName. It gives me an error on the first run. This is the error I'm getting in the console. I realize there are lots of other question asking basically the same things and I've tried pretty much every fix I could find. Also, the error that I'm getting is a bit different since there are way too many backslashes in between each directory and no other post has had a similar error.
Here is what I've already tried:
Start packager with npm start -- --reset-cache
Start packager with npm start -- --root '/my/project/root/'
Tried downgrading to react-native v0.44.0 as well as many other version
Tried downgrading react to a few different versions
Basically tried multiple different versions of every dependency in the initial react native app
Double check android studio settings. I've gone through the react native docs multiple times. No luck.
Re-installed everything: Android Studio, Node, npm, react-native-cli, JDK
I'm completely at a loss.
Hi I am trying to run my react-native android application on the device. It was working well, suddenly I am getting an error on running application.
DeviceInfo native module is not installed correctly
I have checked this DeviceInfo native module is not installed correctly but it did not work for me. I restarted my system to kill all process.
Can anyone help me how to solve this issue ?
D:\React Native\ReduxExample1>react-native -v
react-native-cli: 2.0.1
react-native: 0.44.0
D:\React Native\ReduxExample1>
I was running different application which is also built in react-native but did not run react-native server of that application. This was just my bad :)
I think this type of errors when you are not in the right packages. So as per my experience Make sure you have the right packager running in the terminal, sometimes you may have a packager associated with another react native project running, this happens because when you stop running a React Native project from Xcode or Android Studio, it doesn't stop the packager in the terminal, and when you start/open another React Native project in Xcode or Android Studio, it simply checks if a packager is running, doesn't check if it's associated with the current project. So make sure you stop all of the packager instances in the terminal and then open the React Native project again.
I have developed an app using Sencha Touch 2.1.0. My app is running successfully on the emulator, but when I try to launch on any device (I have tried four different devices), the default Sencha splash screen does not disappear and the app does not start working. The error I found from the log-cat is:
12-27 18:39:21.580: E/Web Console(23413): Uncaught Error: [Ext.Loader] Failed loading 'file:///android_asset/touch/src/event/Dispatcher.js', please verify that the file exists at file:///android_asset/touch/sencha-touch.js:8321
12-27 18:39:21.580: E/Web Console(23413): Uncaught Error: [Ext.Loader] Failed loading 'file:///android_asset/touch/src/event/publisher/Dom.js', please verify that the file exists at file:///android_asset/touch/sencha-touch.js:8321
It looks like you are using a development build of the app where it loads in each class individually. I always use sencha's build tools, and build for "testing" or "production" before I go onto the device. The call to build for testing, if called from your project root is:
// this figures out all your project dependencies
sencha app resolve http://localhost/ref/to/your/project/index.html dependencies.json
// this will build your project for testing, which does not remove white
// space or comments, and does not generate cache.manifest files for HTML5 caching
sencha app build -e testing
The build destination directory is configured in the app.json file and will have some lines similar to:
"buildPaths": {
"testing": "../builds/testing",
"production": "../builds/production",
"package": "../builds/package",
"native": "../builds/native"
},
My development flow is to build in the browser, then build for "testing" when I need to test on the device. Here is my build.sh script, which I run from my application root. This script generates all my dependencies, builds for testing (based on my app.json buildPaths params), changes directory to a directory called "builds/android/" where I hold my android (phoneGap) project, then builds the project to the device I have attached via USB:
sencha app resolve http://localhost/careathand/front/mobile/dev/index.html dependencies.json
sencha app build -e testing
# build the application on the device with cordova
cd ../builds/android/
./cordova/debug
./cordova/log | grep Cordova
Now all I have to do is run the following command from my project root:
sh build.sh
A round about answer, but hopefully this helps streamline your dev process and ultimately fix the problem.
$ sencha package run packager.json
seems not to work on Android 4.x.
Could you try this instead of?
$ sencha app build native
$ adb install build/[yourProject]/[yourAppName].apk