React Native 0.55.2 Android looks for index.android.js - android

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'.

Related

How to set up an existing React-Native project from a new computer for the first time?

So I recently started working with my friend on his app project and I've had trouble building his react-native based project. It's both ios and android.
On android, I can get as far as building, but when I run the app shuts down instantly or shows a red screen with some firebase error.
On ios, I get a build error.
My question is: what do I need to install when I first pull the repo from github? I run '''yarn install''' straight away and run '''pod install''' from the ios folder but that isn't enough. Anything I should run for android more than the yarn install command I had already used?
Thanks!
It seems your development environment is not set up yet. Follow this link to set up your environment.

DeviceInfo native module is not installed correctly in react native

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.

Ionic Build or Ionic Run builds the wrong app

I am trying to build or run an Ionic Cordova App. But it always builds a default app with playlists.
OS is Windows 10
I do the following from my command prompt:
c:\users\martijn\documents\ionic start testapp blank
c:\users\martijn\documents\testapp\ionic run android
now it is building a different app then in my app directory. When I do ionic serve I see the right app in my browser. Can't figure out why running or building gives me a different app, I think it is a default example app.
Can somebody help?
See link here:
https://github.com/driftyco/ionic-cli/issues/1283
Appears you may have to delete the the last apk file from platforms\android\build\outputs\apk

Android Library Project with React Native

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.

Phonegap app for iOS without Phonegap Build

So I asked and answered the question [how to do Phonegap 3.0 without Phonegap Build][1]. Now my app is ready for iOS as well (I think) and it's time to start deploying and debugging for that platform.
The formal question: how can I add the iOS platform to a Phonegap 3.0 project?
This answer is still in progress.
Goals I've achieved:
Compiling the project in command line, then running on device or sim using xCode
Attempts failed:
Compiling and running (device/sim) all from the command-line
1. Creation
I could easily add the iOS platform as described in the docs' iOS Platform Guide.
Basically, if the project already exists because you did Android first, this is how you set up the iOS app structure.
$ add platform ios
Then you should add files to the main /www folder if you didn't already have them from your Android work. Then this takes care of creating the app in debug form:
$ cordova prepare //Creates all the necessary source filed
$ cordova compile //Creates an ipa file
//Alternatively, do both in one go with cordova build
2. Deploying to device
But it is completely unclear how to use the command line interface to actually deploy the test app to device or emulator.
When you attach a physical iOS device, and simply try this from the main project folder...
$ cordova run ios
You get a pretty clear answer:
[Error: An error occurred while running the ios project. Targeting a device is not supported currently.
]
So I've resigned myself that for device testing, I must still use xCode. No biggie. However, xCode cannot "refresh" the project by itself after you've updated your files, so in between deploys you must go back to the command-line to recompile the iOS app.
Strangely, when I update my code, I do need to use "cordova run ios" (even with the above error) in order for the the /platforms/ios/www folder to be updated. So this is what works and does not work:
$ cordova run ios
//Rebuilds the app with main /www files successfully,
//then tries to deploy to device and fails in that.
$ cordova prepare ios
//Does not rebuild with main /www files
//(Also does not deploy but that is not its intended function)
And remember that you also need to clean your xCode project in between runs. So the sequence is:
Previous run
Edit your code
In console, do: cordova run ios
In xCode, Menu bar > Product > Clean product
in xCode, Run
3. Deploying to emulator
Still, "deploying to device is not possible" begs the question "What about emulator?"...
The docs page on the 3.0 command-line interface mentions you should enter the command
$ /path/to/my_new_project/cordova/run
This had me all confused. What kind of path is that? From where are you supposed to run it? Is it a nice way of providing a command you can run from anywhere? Why force me to enter my annoyingly long project path for each command?
Confusingly, the run command doesn't work if you actually go to the "platforms/ios/cordova" directory where the run executable is located.
The trick is to be one directory lower, i.e. at the /platforms/ios subfolder of your Cordova app project. There you type "cordova/run". Then in my case it starts building.
4. Install "ios-sim"
But that was not the end of it. I subsequently get an unanticipated error about "ios-sim" not being installed.
[...]
** BUILD SUCCEEDED **
Error: ios-sim was not found. Please download, build and install version 1.5 or greater from https://github.com/phonegap/ios-sim into your path. Or 'brew install ios-sim' using homebrew: http://mxcl.github.com/homebrew/
Fortunately that project webpage has adequate documentation on how to install. However, even after adding the ios-sim directory to my $PATH, when I want to emulate I get the following error.
$ cordova emulate ios
[TypeError: Arguments to path.join must be strings]
This is where I am currently stuck. My path looks exactly like this (all in one line):
export PATH=${PATH}:/Applications/adt-bundle/
sdk/platform-tools:/Applications/adt-bundle/sdk
/tools:%JAVA_HOME%\bin%ANT_HOME%\bin:"/Users/
cool/Library/Developer/iossim"
What am I doing wrong? I've tried with and without doublequotes, and I've even renamed the ios-sim directory to iossim in case the hyphen was the problem. No effect.
So no simulator for now.
5. Install to iOS App Store
This is the point where Phonegap really leaves you out in the woods. Maybe because they want you to use their paid app publishing service, but also because the process of publishing an iOS app is basically soemthing you do using xCode, iOS Developer Portal, and iTunes Connect.
So here that goes:
You need to have all the right certificates and profiles for your app (yes, it's a bunch of incomprehensible virtual documents that all require each other, Apple is like the Soviet Union of app stores).
You request those certificates and profiles in the iOS Developer Portal, save them to disk, then double-click them so that xCode knows you have them and will include them in your app.
This is the docs page for xCode 4 on how to publish your app.
The most counter-intuitive bit is that in order to publish your app, you first have to create an archive of it in xCode (Open your project in xCode > menu bar > Product > Archive).
When the archive is made, you will see it in the Organizer view under the Archives tab. There should be two buttons: Validate and Distribute. Validate checks and includes all your profiles and certificates in the app, and it also checks for errors like a wrong version number.
Distribute does what it says: it sumbits the app to the App Store.
Congratulations! (Now wait five days)

Categories

Resources