Ionic: Adding platform gives error - android

Having first Ionic encounter, I am setting the environment up for an Android app on OSX Yosemite. By running the command sudo ionic platform android I am getting following error:
Error: %s Error: ENOENT, no such file or directory '/Users/myUser/hooks'
at Error (native)
at Object.fs.readdirSync (fs.js:761:18)
at Object.setHooksPermission (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/hooks.js:116:24)
at Object.IonicTask.run (/usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:51:13)
at Object.run (/usr/local/lib/node_modules/ionic/lib/cli.js:95:32)
at Object.<anonymous> (/usr/local/lib/node_modules/ionic/bin/ionic:9:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
Updated the hooks directory to have execute permissions
Error happened { [Error: ENOENT, open '/Users/myUser/config.xml'] errno: -2, code: 'ENOENT', path: '/Users/myUser/config.xml' }
Error: ENOENT, open '/Users/myUser/config.xml'
at Error (native)
Versions after running their upgrade:
├── cordova#5.4.1
└── ionic#1.7.12

It should be this,
$ ionic platform add android
Also, you'd better not run command with sudo or you might face with troubles with permission some time later.

please go to myApp folder
then run the command :
ionic platform add android

My android platform was corrupt, after removing it and adding it properly, the issue got solved

go to ionic app folder where your config.xml file exists.and then execute this command.
$ cd Myapp
where folder structure should look like this
$Myapp -> ls
$Myapp -> bower.json gulpfile.js ionic.project platforms README.md scss
config.xml hooks package.json plugins resources www
$Myapp -> ionic platform add android

Related

error while trying to add android platform with ionic

When running the command ionic cordova add platform android I am getting the following error.
I've completely uninstalled Nodejs and reinstalled Ionic and Cordova globally from scratch but I can not figure out why this error is occurring.
The error also occurs when I execute the command cordova -v
cordova.cmd platform add android --save
C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:347
throw err;
^
Error: Command failed: wmic os get Caption
Description = O servi�o n�o pode ser iniciado porque est� desativado ou n�o tem dispositivos ativados associados.
at makeError (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\execa\index.js:338:15)
at windowsRelease (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\index.js:34:24)
at osName (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\os-name\index.js:39:18)
at new Insight (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\node_modules\insight\lib\index.js:37:13)
at Object.<anonymous> (C:\Users\LUIZ\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:26:15)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
This error occurs every time I run the command, I can not add the Android platform. I need to run ionic cordova run android to open in my emulator I created in Android Studio.
npm list -g --depth=0
C:\Users\LUIZ\AppData\Roaming\npm
+-- #angular/cli#8.0.2
+-- cordova#9.0.0
`-- ionic#5.0.1
I tried many things, but I had to:
Windows-Key (Keyboard)
System Environment Variable
Environmentsvariables..
Select Path Variable and edit
Add the path to your wbem
example: c:\Windows\System32\wbem
Restart cmd
Enjoy

Cannot Find entry file index.ios.js in any of the project roots ["/Users/neo/newProjects/F2"]

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
`

Failed to find 'ANDROID_HOME' environment variable. Failed to find 'android' command in your 'PATH'

I'm trying to build the default Hello World phonegap project for android on my ubuntu system, but I am confronted by errors at every step.
SHORT VERSION:
I cannot create a phonegap project without sudo (not quite true--see below).
After creating a phonegap project with sudo, I cannot build android without sudo.
When I type "sudo phonegap build android", I lose my path settings, resulting in an error.
I have attempted a fix for this last problem by including the line "alias sudo='sudo env PATH=$PATH'" in.bashrc, as suggested in sudo changes PATH - why?, but it doesn't work. I also added ANDROID_HOME and PATH lines to .bash_profile, with no success.
I think the 'android' command actually is in my path.
Here are the last lines of my .bashrc:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
alias sudo='sudo env PATH=$PATH'
I also have the following in ~/.bash_profile:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
LONG VERSION:
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Error: EACCES, permission denied '/home/gregory/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at Object.create.all.get (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:123:23)
at checkForUpdates (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:64:20)
at cli (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:114:5)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin/cordova:41:1)
at Module._compile (module.js:456:26)
gregory#gregory-1001PXD:~/javascript$ sudo phonegap create phonetest
[sudo] password for gregory:
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ sudo phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /home/gregory/javascript/phonetest/icon.png
Running command: /home/gregory/javascript/phonetest/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
Bu I think the android command is in my PATH (it tab-completes).
NOTE: I can create a project without sudo if I remove the file update-notifier-cordova.json. But it still produces an error, as follows.
gregory#gregory-1001PXD:~/javascript$ sudo mv /home/gregory/.config/configstore/update-notifier-cordova.json ~/Documents/
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ phonegap build android
[phonegap] executing 'cordova platform add --save android'...
Error: Failed to fetch platform android#~4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES, open '/home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'
[phonegap] executing 'cordova build android'...
Error: No platforms added to this project. Please use `cordova platform add <platform>`.
This is documented in their JIRA: https://issues.apache.org/jira/browse/CB-10062
Check the ownership of the file using:
ls -al /home/gregory/.config/configstore/update-notifier-cordova.json
If it is root, you may want to try reinstalling cordova - otherwise use the workaround suggested by running:
chmod 744 /home/gregory/.config/configstore/update-notifier-cordova.json

How to locally build an ionic app taken from a .git repository

I was trying to build Moodle's ionic mobile app locally on Windows by following the below steps:
cd project-directory
ionic platform add android
The command prompt returns the below error:
Updated the hooks directory to have execute permissions
Adding android project...
Running command: cmd "/s /c "C:\Users\zameer\.cordova\lib\npm_cache\cordova-andr
oid\4.1.1\package\bin\create.bat D:\ionic\moodlemobile2-master\moodlemobile2-mas
ter\platforms\android com.moodle.moodlemobile "Moodle Mobile" --cli""
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.moodle.moodlemobile
Name: Moodle Mobile
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.1.1
Running command: "C:\Program Files\nodejs\node.exe" D:\ionic\moodlemobile2-maste
r\moodlemobile2-master\hooks\after_prepare\010_add_platform_class.js D:\ionic\mo
odlemobile2-master\moodlemobile2-master
add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" D:\ionic\moodlemobile2-maste
r\moodlemobile2-master\hooks\after_prepare\020_add_ios_transport_security.js D:\
ionic\moodlemobile2-master\moodlemobile2-master
module.js:338
throw err;
^
Error: Cannot find module 'plist'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (D:\ionic\moodlemobile2-master\moodlemobile2-master\ho
oks\after_prepare\020_add_ios_transport_security.js:10:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
Error: Hook failed with error code 1: D:\ionic\moodlemobile2-master\moodlemobile
2-master\hooks\after_prepare\020_add_ios_transport_security.js
Everything seems normal till the below part of the above error block:
throw err;
^
Error: Cannot find module 'plist'
My aim is to run this project locally to see ionic in action
What is this plist module? Why is it not getting detected?
After cloning a Git repository that contains a Ionic app, you need to run these 2 additional commands:
Install Node.js dependencies
npm install
It will install all the Node.js dependencies in the local node_modules folder. The modules considered are the ones listed under dependencies and devDependencies in the package.json file located at the root of the cloned Git repository.
Install Cordova plugins
ionic state restore
This command looks at the cordovaPlugins and cordovaPlatforms attributes in the package.json file and install the additional platforms and plugins code required for the app.
You did not execute npm install so you are missing the required packages.
Read this on what need to be done to work with ionic.
Go into the project folder where the package.json is in and execute the npm install form that folder.

"cordova platform add android" fails with unexpected error

i am trying to install Phonegap on Ubuntu 13.04, i have installed the Android SDK with all available Packages, but running the following command:
cordova platform add android
fails with an unexpected error:
[Error: An error occured during creation of android sub-project. An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &>/dev/null exited with 1
Deleting project...
I have set the PATH Variables for Android (tools / platform-tools) and java and ant are installed.
Why does this happen? How can i get a more detailed error message?
have you tried running command with sudo?
it could be a permissions issue.
If still not working, try running it using verbose mode i.e. sudo -d cordova...
In case this is due to activity name whitespaces, see comments for this answer.
There is an issue reported in https://issues.apache.org/jira/browse/CB-4198, for which I've sent a pull request to remove whitespaces https://github.com/phonegap/phonegap/pull/39.
As #José said, the "hello" example doesn't work because spaces are not allowed.
Changing it to "HelloWorld" solves the problem.
remove the space in between name tags in config.xml
MyAppName< name>
In my case, using debian wheezy, the example from: http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface does not work with this error:
[Error: An error occured during creation of android sub-project. An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &>/dev/null exited with 1
Deleting project...
]
After adding $JAVA_HOME (Java sun, with openjdk did't work) and $PATH the andriod sdk path to .../sdk/platform-tools:../sdk/tool
The solution in my case was the project name:
The example that doesn't work:
cordova create HelloWorld com.example.hello "Hello World"
THIS works:
cordova create HelloWorld com.example.hello HelloWorld
Make sure your package and project names are correct, following the com.mycompanyname.myappname format without any numbers or dashes.
Here's the issue being tracked by PhoneGap.
If you open up the create file (phonegap-2.7.0/lib/android/bin/create) with textEdit, there is a line that lists
ANDROID_BIN=”${ANDROID_BIN:=$( which android )}”.
The “which android” is the cause of the issue
If you replace this line with the full path to your android tools (SDK), it should resolve the issue. It looked like this:
ANDROID_BIN=/Users/cswjs/Documents/Dev/adt-bundle/sdk/tools/android
OR try modify ~/.bash_profile using open ~/.bash_profile to full PATH
export PATH=${PATH}:/Users/cswjs/Documents/Dev/adt-bundle/sdk/platform-tools:/Users/cswjs/Documents/Dev/adt-bundle/sdk/tools
And use cordova create foo com.example.foo foo to create new project named foo. Make sure project name should be same.
Hope this could help someone!
IN my case there are many places in create script where u need to remove >null to see real logs. and i finally resolved my issues by
sudo chown -R sachinsharma ~/.cordova

Categories

Resources