i want to make release for android application in react native so when i generate build i got below error message like
Error:Execution failed for task ':app:bundleReleaseJsAndAssets'.
A problem occurred starting process 'command 'node''
see attachment also
any idea how can i solve this ? your all suggestions are appreciable
After spending 2 days I resolved it, Please follow the below steps:-
1) Stop Running Gradle
$ cd RectNatoveProjectName & cd android (Open your project and go to android folder)
$ ./gradlew --stop (Run this command to stop old running Gradle service )
2) Update the android app build gradle
project.ext.react = [
nodeExecutableAndArgs : ["/usr/local/bin/node"]
];
3) Get Node details
$ which node
> (Result will be like "/usr/username/.nvm/versions/node/v10.7.0/bin/node")
4) Link node (very imp step copy the above result in step 3)
- ln -s /usr/username/.nvm/versions/node/v10.7.0/bin/node /usr/local/bin/node
5) If Step - 4 return file exist
- then to go the folder /usr/local/bin/ and delete the "node" file and perform the step -4 again.
6) If Step - 4 run successfully then this node issue will be resolved.
It can have following possible solutions:
1] You need to change the node executable path in your build.gradle(i.e android/app/build.gradle) file as follows:
project.ext.react = [
nodeExecutableAndArgs : ["/usr/local/bin/node"]
];
Or
2] You need to close your Android Studio and need to run below command from project root directory:
cd android
./gradlew assembleRelease
Or
3] You need to simply run "./gradlew --stop" command and then run "./gradlew assembleRelease" command
Add the below following code in app/build.gradle at the end of the file.
afterEvaluate{
android.applicationVariants.all { variant ->
variant.ext.bundleJsAndAssets.enabled = false
}
}
Related
We created a ionic app with angular. When we use
ionic serve
Then its working fine.
But when we are generating android apk then we are getting this error:-
* Where:
Build file '/home/ankur/projects/ionicdesign/ionic-roots_v101/ionic
apps/kisansanchar/medical/platforms/android/app/build.gradle' line: 20
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not initialize class com.android.build.gradle.internal.crash.PluginCrashReporter
Here is complete log details:-
Paste Bin
Any idea about this error?
I've had the same issue.
Digging into gradle command with --scan, I've found the problem.
My ~/.android was owned by root, so my build (launch by my user) failed to read/write into this directory.
Solution: sudo chown -R you:you ~/.android
For me, it was the kotlin_version in build.gradle, the one used for building is lower than what was configured for my IDE, so what I did is deleted my .gradle caches by typing this in terminal rm -rf $HOME/.gradle/caches/
Then restarted my project in my case it was a flutter project so flutter run is the command. everything is taken care of after that.
When I run command
ionic cordova run android
build is succeeded but app cannot be run on my android device.
The error log is as:
BUILD SUCCESSFUL in 4m 7s
47 actionable tasks: 45 executed, 2 up-to-date
Built the following apk(s):
ANDROID_HOME=C:\Users\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_121
No target specified, deploying to device 'UGM0217321003049'.
Skipping build...
Built the following apk(s):
Error: Could not find apk architecture: arm build-type: debug
[ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Under the directory platforms/android/build/outputs/apk, there is only one folder called debug under which there are two file android-debug.apk and output.json.
apk
|---debug
|---android-debug.apk
|---output.json
I suspect there should be some arm architecture file in apk directory, but I don't know how to generate it.
Can you help me to solve this run android error?
To avoid extended discussions in comments, let me summarise the workaround as below:
Try to run below command to build the apk first.
cordova build android
or
ionic cordova build android
Look for the apk from platforms\android and manually install it.
How to automatically build the android-debug.apk in app folder?
the .json file is auto generated, usually you don't need to touch it.
By default, the apk path is under app/build/outputs/apk, you can copy it to a custom location wherever you prefer, for your case, maybe it is app/ root directory. You can do this with many means, e.g. bash scripts. Below gradle snippets is how I do this task, just copy below code to the end of your app/build.gradle:
def capitalizeFirstLetter(s) { s[0].toUpperCase() + s[1..-1] }
def publish = project.tasks.create("copyApks")
publish.description "Copies apks to custom directory"
android.applicationVariants.all { variant ->
def customPath
variant.outputs.all {
customPath = "$projectDir"
def capitalizedVariantName = capitalizeFirstLetter(variant.name)
def task = project.tasks.create("copy${capitalizedVariantName}Apk", Copy)
task.from(outputFile)
task.into(customPath)
task.dependsOn variant.assemble
publish.dependsOn task
}
}
From your command line, run ./gradlew copyApks or gradlew copyApks on macOS or Windows respectively.
Then you will find your apk is under app\ directory.
Actual Behavior
Instead of launching, I get a red screen and this error message when launching a react native projects from scratch: Cannot Find entry file index.ios.js in any of the project roots ["/Users/neo/newProjects/F2"]
Expected behavior
Launch of a clean app starter
What I am trying to do
I'm trying to init and run a react-native project from scratch in the android and ios simulator, but I'm getting the following error.
What I have tried
I've tried doing the following:
Install via documentation
Moving through the install steps outlined here several times:
https://facebook.github.io/react-native/docs/getting-started.html
NPM Install
Performing NPM Install from within the project folder
Editing .profiles ( android )
editing the ~.profiles file, to set the android home variable.. this is what it looks like now:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" $
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools`
Npm start
Running npm start and checking activity on the port, ( was the package manager running )
checking the port for activity
( forget how, verified its available )
Code that worked for someone...
I have also tried running this code in the terminal
react-native bundle \
--entry-file=index.ios.js \
--platform=ios \
--dev=false \
--assets-dest=./production/ios \
--bundle-output=./production/ios/ios.jsbundle
After reviewing this article https://github.com/facebook/react-native/issues/8664
And got this error message:
ENOENT: no such file or directory, open './production/ios/ios.jsbundle'
I noticed this suggestion
rerunning npm install and rnpm link
I tried running rnpm link, but got "no such command found"
after reading this article
Entry file error in react native from packager
In the same article I saw this:
"Figured out that after updating to RN 0.28 my app is spitting this issue due to incompatible dependencies. This is how I solved this problem"
rm -rf node_modules
npm cache clean
Then open package.json except react-native change all package versions to *
Then run
npm update --save
npm update --save-dev
Check package if package.json is updated with version numbers, if not verify from npmjs and update manually
Delete app from the device and try to run again
But I cannot discern what the advisor is doing here... and the logic behind it... if it seems relevant, can someone comment on this?
Terminal Output
I am getting this in the terminal:
Loading dependency graph, done.
error: bundling: Error
at DependencyGraph._getAbsolutePath
(/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:272:11)
at DependencyGraph.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:216:26)
at Resolver.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Resolver/index.js:106:27)
at _resolverPromise.then.resolver (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Bundler/index.js:561:62)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.ios.js` 0.0% (0/1), failed.
Versions
Node v7.9.0
react-native-cli: 2.0.1
react-native: 0.44.0
Homebrew 1.2.0
Just updated xcode
OSX 10.11.6 (15G1004)
What I notice
I notice that it seems to be looking in this file.. ["/Users/neo/newProjects/F2"] whereas in some locations on my machine the files are organized Users/Neo/... ( capital username ) ... and I sense that has something to do with this.
also, on project build it does throw this warning... not sure what it means...
"react-native#0.44.0" has unmet peer dependency "react#16.0.0-alpha.6"
Any suggestions or ideas?
update
tried changing directories out of the users folder and initializing
here is what I got in the stacktrace
2017-05-02 09:25:21.478 xcodebuild[52491:5334564] Error saving log: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={NSFilePath=/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog, NSLocalizedDescription=No such file or directory} | User info: {
NSFilePath = "/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog";
NSLocalizedDescription = "No such file or directory";
}
Installing build/Build/Products/Debug-iphonesimulator/F4.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/F4.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Also, tried installing expo and running from there...
Heres what the terminal shows
Error sourcing shell startup scripts: /Users/neo/.bash_profile: line 2: rbenv: command not found
/Users/neo/.bash_profile: line 4: rbenv: command not found
/Users/neo/.bash_profile: line 5: rbenv: command not found
/Users/neo/.bash_profile: line 7: rbenv: command not found
/Users/neo/.bash_profile: line 9: rbenv: command not found
/bin/bash: shell_session_update: command not found
.
Please run npm install -g exp && exp path``
10:25:22 AM
Starting React Native packager...
10:25:31 AM
Scanning 656 folders for symlinks in /code/my-new-project/node_modules (11ms)
10:25:32 AM
Loading dependency graph.
10:25:32 AM
Running packager on port 19001.
10:25:32 AM
10:25:37 AM
Dependency graph loaded.
10:25:51 AM
Project opened! You can now use the "Send Link" or "Device" buttons to view your project.
10:36:58 AM
Couldn't start project on Android: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
`
I'm building a hybrid app with cordova. The setup has been tested with simple application. Both android and iOS build works fine.
After switching to a more complex application, the following error occurred. I googled and found some suggested solution but none of the worked.
I'm new to this so any suggestion appreciated.
:processArmv7DebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processArmv7DebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/Cellar/android-sdk/24.4.1_1/build-tools/23.0.2/aapt'' 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: 28.659 secs
ERROR building one of the platforms: Error code 1 for command: /Users/wliang/work/hzoom/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/wliang/work/hzoom/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /Users/wliang/work/hzoom/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/wliang/work/hzoom/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
In my case I discovered the error with the follow command:
cordova build android -- --gradleArg=--info
I have found:
Executing task ':processArmv7DebugResources' (up-to-date check took 0.009 secs) due to:
Input file /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz has been added.
Starting process 'command '/Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt''. Working directory: /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android Command: /Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt package -f --no-crunch -I /Users/astaniscia/Library/Android/sdk/platforms/android-23/android.jar -M /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/manifests/full/armv7/debug/AndroidManifest.xml -S /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/merged/armv7/debug -A /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug -m -J /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/generated/source/r/armv7/debug -F /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/resources-armv7-debug.ap_ --debug-mode --custom-package com.navionics.poc -0 apk --output-text-symbols /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/symbols/armv7/debug --no-version-vectors
Successfully started process 'command '/Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt''
Unable to add '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/resources-armv7-debug.ap_'
:processArmv7DebugResources FAILED
:processArmv7DebugResources (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.312 secs.
and this line helped me
Unable to add '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz': file already in archive (try '-u'?)
for me solve the problem... I removed the gzip and now all work fine!
I had the same issue and this is what I found to be the issue.
The bower components folder - which normally defaults to www/lib/ using cordova - was the culprit in my case.
I had modified one of the bower components, to do that I had to first run npm install inside the specific package that I was updating. After doing that there was a node_modules folder inside the specific component I was updating i.e. www/lib/{name_of_component}/node_modules. Basically this specific node_modules folder is only used for build tools concerning the specific component, and thus it is not needed once you are done updating it and want to build the whole app. Some of the modules inside that specific component's node_modules may conflict with the projects node_modules i.e. {your_app}/node_modules - this can cause problems. In my case the conflict was with the semver module.
So in my case the solution was to delete that specific node_modules folder. After that I could build my app without any issues.
Hopefully this helps.
This is an old issue, but I recently came upon the same one and hope my experience might help someone else in the future.
After a solid day of looking around I realized it had to do with my plugins. For some reason there was an unused dependency in package.json that wouldn't allow it to build.
In my case, it was Firebase, and after removing it from package.json and the plugins folder I ran
cordova platform remove android
and
cordova platform add android
then built it again and all of a sudden it was up and running!
This error shows up because you have one or several accentuated filenames in your project folder. In my case, it was an image with the char "ç".
This topic can help rename automatically: https://superuser.com/questions/617517/remove-all-illegal-characters-from-all-filenames-in-a-given-folder
For me it was the node_modules folder inside www that caused the problem.
The solution is to copy your www to another folder and exclude node_modules and you will be fine.
The thing that worked for me :
cordova plugin add cordova-android-support-gradle-release
Thanks to lohith95
from https://forum.ionicframework.com/t/android-build-broken-after-gradle-dependencies-update-execution-failed-for-task-processdebugresources-com-android-ide-common-process-processexception-failed-to-execute-aapt/109982/170
This is might because you use crosswalk,
You can try the following commands:
sudo ionic cordova platform remove android
sudo rm -rf ./node_modules
sudo npm install --unsafe-perm=true --allow-root
sudo npm install --unsafe-perm node-sass
sudo ionic cordova platform add android#6.4.0
sudo ionic cordova plugin add cordova-android-support-gradle-release
sudo ionic cordova build android
I just updated my gradle from version 2.2 to latest one 2.8. I didn't have any issue with findbugs on version 2.2.
I'm working on an Android project that contains two modules. In order to use find bugs in both modules I have following configuration on main build.gradle file of root directory.
configure(allprojects) {
apply plugin: 'findbugs'
task findbugs(type: FindBugs) {
ignoreFailures = false
effort = "max"
classes = fileTree('build/intermediates/classes/')
source = fileTree('src/main/java')
classpath = files()
excludeFilter = file("exclude.xml")
reportLevel = "high"
reports {
xml.enabled = false
html.enabled = true
}
}
}
When I run ./gradlew findbugs on my local machine everything is fine and build is successful however when I push my PR to Github and Trivis tries to build then I get error:
:findbugs UP-TO-DATE
:passenger-app:findbugs
:passenger-sdk:findbugs FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':passenger-sdk:findbugs'.
> FindBugs rule violations were found. See the report at: file:///home/travis/build/project-name/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
I'm really confused why I have no problem on my local machine while Travis shows error! I tried to print out the contents findbugs.html on Travis but I got permission denied :(
I'm using java 1.8 while Travis is using 1.7. Does problem relates to this? Thanks
Update:
In order to print the contents of findbugs.html on Trivis I created a print_findbugs.sh and this is its contents.
#!/usr/bin/env bash
echo '**********************'
echo '*** Print Findbugs ***'
echo '**********************'
echo file:///home/travis/build/company/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
Then I set sudo true in my .travis.yml file. What I have in this file.
sudo: true
language: android
android:
components:
- build-tools-23.0.1
- android-23
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
env:
global:
// some settings are there
before_cache:
# Delete the gradle lock file which forces creation of a new build cache
- rm ~/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- ~/.gradle
before_script:
# Overwrite the keystore if it is a pull request
- ./before_script.sh
script:
# Override Travis default script to not run connectedCheck until this bug is fixed:
# https://code.google.com/p/android/issues/detail?id=59592
- ./gradlew clean build findbugs -PdisablePreDex
- ./print_findbugs.sh
before_deploy:
# Clean up the output folder
# Link up the new builds into individual html files
- ./before_deploy.sh
after_deploy:
# Upload to...
and finally my travis prints:
:findbugs UP-TO-DATE
:passenger-app:findbugs
:passenger-sdk:findbugs
FindBugs rule violations were found. See the report at: file:///home/travis/build/company/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
BUILD SUCCESSFUL
Total time: 8 mins 9.966 secs
The command "./gradlew clean build findbugs -PdisablePreDex" exited with 0.
$ ./print_findbugs.sh
/home/travis/build.sh: line 41: ./print_findbugs.sh: Permission denied
The command "./print_findbugs.sh" exited with 126.
before_cache
$ rm ~/.gradle/caches/modules-2/modules-2.lock
cache.2
Done. Your build exited with 1.
I don't use it and I need more information about the permission denied.
Html reports
In the past, I printed html reports using Travis-ci, point 5 here. I downloaded lynx using apt-get (it's not possible now using container-infrastructure and sudo: false) and converted and printed the reports.
before_script:
# - echo 'LOGCAT'
# Check logcat debug output: http://developer.android.com/tools/help/logcat.html
# Check debugging log: http://developer.android.com/tools/debugging/debugging-log.html
# Comment the lines belows to debug output and redirect it to a file. Custom tags for your app.
- adb -e logcat *:W | tee logcat.log > /dev/null 2>&1 &
after_failure:
# - echo 'FAILURE'
# Check apt configuration: http://docs.travis-ci.com/user/ci-environment/#apt-configuration
# Comment out the lines below to show log about tests with app name customized on exports section.
- sudo apt-get install -qq lynx
- export MOD_NAME=yourappmodulename
- export LOG_DIR=${TRAVIS_BUILD_DIR}/${MOD_NAME}/build/outputs/reports/androidTests/connected/
- lynx --dump ${LOG_DIR}com.android.builder.testing.ConnectedDevice.html > myConnectedDevice.log
- lynx --dump ${LOG_DIR}com.android.builder.testing.html > myTesting.log
- for file in *.log; do echo "$file"; echo "====================="; cat "$file"; done || true
Xml reports
Can be used in both, legacy and container based infrastructure.
I read you can enable xml reports like this:
reports {
xml.enabled = true
html.enabled = true
}
You can easily print xml reports on Travis-ci using cat like here:
- cat ${TRAVIS_BUILD_DIR}/ui/espresso/*/app/build/outputs/androidTest-results/connected/* # logs
Adding * will include all the subfolders at this point.
You need to first find locally the folder for the xml reports, in my case is not the same folder than html, and add to your travis.yml file something like this:
after_failure:
- cat /home/travis/build/*/passenger-android/passenger-sdk/build/reports/findbugs/*
This doesn't solve your issue but perhaps helps to find reason.
Update:
I suggest you to try to use cat and the xml version without the script first.
A good explanation about the permission issue here and how to solve it making the file executable:
before_script:
- chmod +x yourscript
Update 2:
A better approach to fix the permission denied issue explained here.
Use this and commit the changes:
git update-index --chmod=+x yourscript
In my case, ignoreFailures was true, but nevertheless the findbugs task was failing after upgrading gradle because build.gradle was depending on findbugs:annotations:3.0.0 instead of findbugs:findbugs-annotations:3.0.1. (Note: annotations vs. findbugs-annotations, which is a new artifact.
Finally I was able to get everything passed.
I first used following command rather than simple $ ./gradlew findbugs.
./gradlew clean aGD findbugs -PdisablePreDex
aGD is abbreviation of my task something like assembleDebug.
I could see a lot of complains by gradle. Probably Travis was showing this (afterDebug) but since it prints html page in console is not human readable. So I added filters into Findbug's exclude file (ref) in order to pass Findbugs check.
I was successful! Once I pushed my code, Travis failed again.
But since I printed out Findbug's output on Travis and there was only an issue I could find it in my code and Fix it. After that Travis didn't failed and passed my PR.
So the problem is still exist unfortunately. I can get Findbugs passed on my local project while Travis sometimes finds more issues. I'm suspicious that Travis is able to load recent versions of Findbugs but mine isn't able, due to cache things. But yes, this is my assumption!