ReactNative assembleRelease apk fails to find index.android.js - cross-platform

node 6.11.2
npm 4.6.1
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory (???)
macOS 10.12.6
Used React Native to create a new app from scratch. npm start works like a charm when using the expo app on my Android and iOS Devices. I'm having troubles to build a release apk for Android. (iOS will be next step.)
I did eject the app and followed the instructions to create a keystore file etc. Everything like it is documented here: https://facebook.github.io/react-native/docs/signed-apk-android.html
In android folder: running ./gradlew assembleRelease results to:
...
:app:bundleReleaseJsAndAssets
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (13ms)
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (16ms)
Loading dependency graph, done.
Cannot find entry file index.android.js in any of the roots: ["/Users/xy/myApp_ReactNative"]
:app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 26.813 secs
After days of trying out different versions and going back and forward, using commands with sudo and looking up alternatives, I'm getting completly lost. Also wondering why it scans twice... how to solve this?

Solved it myself like so: after trying on a Windows10 machine I realized that I might not have setup NDK. Started Android Studio on my mac and in the SDK Manager installed "NDK". Add a local.properties file in the 'app' folder with sdk.dir=pathtoyourSDK. After that: it worked!

Related

native_modules.gradle file is deleting as soon as react-redux is installed

I have created an app in react native for my project. When I copy my projects file in the app folder then run the app it said that in node_module react-redux does not exist then I installed react-redux using npm install react-redux#7.0.3 in my app folder after that when I run run-android command in command prompt for this project it is telling that -
Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist. .
After that, I wiped the data of emulator and run run-android, but it is still giving me the same error and app is not installing in the emulator.
Here is the error which command prompt is displaying :
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Settings file 'E:\AppFolder\MyApp\android\settings.gradle' line: 4
* What went wrong:
A problem occurred evaluating settings 'TribeBond'.
> Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist.
* Try:
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.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 10s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.```
Here I follow these steps to solve my problem-
I build a new app and run it using react-native run-android command.
Then I installed all dependencies one by one, which is going to use in the app.
Then run npm install command in the project.
After that, I re-build the app using react-native run-android.
And Tada! the app is re-built without any error.

React Native not working

I am working on react native and building my app on android pyhsical device but it throws an error.
I have set my JAVA_HOME and ANDROID_HOME variabes but still not working.
This is exactly what it is returning :-
Scanning folders for symlinks in /home/harsh/Desktop/App/node_modules (9ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '10.0.1'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Your error may come from the fact that you have 2 differents jdk installed and, since react should not be used with a jdk > 9 yet, check your Java installation with java -v in order to get the version.

Failed to download any source lists! (node.js v10.7.0 | yarn 1.7.0 | react-native: 0.56.0 | Windows 10)

I am trying to run a hello world application using the steps clarified hear. I am pretty sure I have done all the steps. but when I try to react-native run-android I get the below error.
react-native run-android ouput
C:\Users\Mike-laptop\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\Mike-laptop\AwesomeProject\node_modules (43ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Mike-laptop\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Failed to download any source lists!
java.io.FileNotFoundException: https://dl.google.com/android/repository/repository2-1.xml
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Build Tools revision 26.0.3
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.602 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Please note that I am running everything behind proxy... it is most likely due to the fact that react-native is not using proxy I have setup. I have tried to configure things in different ways.
Internet options
yarn config set proxy http://host:port
yarn config set h t t p s-proxy h t t p://host:port
npm config set proxy h t t p://host:port
npm config set h t t p s-proxy h t t p://host:port
set environment variable
set h t t p s_proxy=h t t p s://127.0.0.1:8123
set h t t p _proxy=h t t p://127.0.0.1:8123
set proxy=h t t p://127.0.0.1:8123
Still no luck :(
Much appreciate any comments.
First, you need to configure your Android env to run Android apps.
Please, take the steps in this link, in the Building Projects with Native Code tab, choose Windows and Android.:
https://facebook.github.io/react-native/docs/getting-started.html
Make sure you install Android SDK build tools 26.0.3 inside Android Studio.

React-Native Android Gradlew installDebug results in build failure

I am running a React-Native app but when I try to gradlew installDebug in the android directory I get a build failure. Here is the info I get when I use:
gradlew installDebug --info
`BUILD FAILED
Total time: 1.118 secs
Stopped 0 compiler daemon(s).
Received result CommandFailure[value=org.gradle.launcher.exec.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':app'.] from daemon DaemonInfo{pid=4326, address=[4c8a3b8f-5957-4911-b262-0e36824d2139 port:54258, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], idle=true, context=DefaultDaemonContext[uid=dbec8c34-89ba-4872-9077-12b4b3ff38a0,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home,daemonRegistryDir=/Users/d0ntg0m0ng/.gradle/daemon,pid=4326,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}.`
This is the error I get when I run gradlew installDebug without --info
`android [router] :> ./gradlew installDebug
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
Cannot evaluate module react-native-couchbase-lite : Configuration with name 'default' not found.`
"react-native": "^0.15.0", is the version of react-native I am using.
this is the repo that the project is fork from
I am trying to setup the app to my genymotion emulator but the build never finishes.
I have already run the commands to react-native start and set up the sync to the couchbase lite server. Not sure if this is relevant info. I am fairly new to native development and I have no idea where to start with trying to debug this.
include ':app'
include ':react-native-couchbase-lite'
project(':react-native-couchbase-lite').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-couchbase-lite/android')
check the file path

Android build error: Cannot evaluate module RCTVideo : Configuration with name 'default' not found

I'm trying to get set up using https://github.com/brentvatne/react-native-video for an android version of a react-native app. After making all the changes to the various gradle files I'm running into this issue below.
I'm a bit of a novice with Android development, and I think I'm just making a silly mistake which is why I'm asking the question here rather than raising an issue. Any advice would be appreciated!
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module RCTVideo : Configuration with name 'default' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.851 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
Edit, settings.gradle looks like this:
rootProject.name = 'app_name'
include ':RCTVideo', ':app'
project(':RCTVideo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
Without seeing the Settings.gradle my guess would be that the project location isn't going into the folder that has the gradle for the android version of the library. I would recommend added /android at the end of the path if it isn't there already.
I will update this answer when the Settings.gradle is provided.
-- Edit after additional information provided --
The version available on NPM is from 3 months ago. It looks like they didn't start adding Android support till Oct 30th and have continued working on it. As such you likely don't actually have the Android code in your node_modules folder. You can either wait till they push an update to NPM or install directly from the git repo. If you go the route of installing directly from the git repo you might want to tag it with a specific commit so you don't keep getting the latest every time you do a npm install.