cordova platform add android new error - android

I hit the following error while executing cordova platform add android:
c:\users\demolition hammer\hellox> cordova platform add android
creating android project...
C:\users\demolition' is not recognised as an internal or extrenal command, operable program or batch file
error: c:\users\demoliton hammer\.cordova\lib\android\cordova\3.4.0\bin\create.
bat:command failed with exit code 1
at childprocess.whendone <c:\users\demolition hammer\appdata\roaming\npm\node_modules\cordova\src\superspawn.js:126:23>
at childprocess.eventemitter.emit <events.js:98:17>
at maybeclose <child_process.js:743:16>
at process.childprocess._handle.oneexit <child_process.js:810:5>
I accidentally deleted the default path of the environment system variable. I have entered a default path for my PC. Apart from that, other paths should be fine. Kindly help me out. This is very frustrating.

a well known problem with the Cordova CLI is that it does not support spaces in the path. Sometimes. In some commands, the path string is properly sanitized. In others, not so much.
Create/Move your project to a directory with alphanumeric characters only and it should work fine.
You could also use the PhoneGap CLI, which has parallel core functionality, but also allows you to upload to PhoneGap build. It handles paths with spaces properly. If it doesn't, I can fix it as I'm the primary maintainer :P

Related

Tools for Apache Cordova Builds Fail on TFS

I'm receiving errors building a Cordova app on TFS 2013. Specifically, it always fails doing some sort of operation on a platform-specific screen.png file. Other posts talk about the problem being related to the file being marked as read-only, but I've been unable to use any of the few solutions I found to get the build to work. Any ideas?
...
Install complete for cordova-plugin-customurlscheme on android. (TaskId:12)
Executing "after_plugin_install" hook for "cordova-plugin-customurlscheme" on android. (TaskId:12)
Searching PlatformJson files for differences between project vs. platform installed plugins (TaskId:12)
No differences found between project and android platform. Continuing... (TaskId:12)
Generating config.xml from defaults for platform "android" (TaskId:12)
Wrote out Android application name to "My App" (TaskId:12)
15:10:15.163 2>MDAVSCLI : error : EPERM, operation not permitted 'D:\Builds\Cordova\MyApp\src\MyApp\platforms\android\res\drawable-land-hdpi\screen.png' [D:\Builds\Cordova\MyApp\src\MyApp\MyApp.jsproj]
Done executing task "MdaVsCli" -- FAILED. (TaskId:12)
You need to check following things:
Make sure the path to "screen.png" isn't set to "Read-Only".
Make sure the account that the build service use has enough permission to access to the file. (Try to run build service with an administrator account)
If it still not work, try to add a step to check out the file before build. Same issue can be referred here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/81d5e57c-49bd-4487-a198-7930b48412b5/error-building-windows-x64-windows-x86-or-windows-anycpu
I finally found a solution. I added a before_prepare hook to remove the read only flag from the files. I added the file hooks/before_prepare/undoReadOnly.bat with the contents below. Note that I had to edit these outside of Visual Studio and save them with ANSI encoding for TFS to be able to read them:
echo before_prepare hook - undoReadOnly
echo MSBuildProjectDirectory=%MSBuildProjectDirectory%
attrib -r %MSBuildProjectDirectory%\MyApp\platforms\*.* /S /D

Titanium Mobile: Cannot build android modules in 3.3.0

Update: To clarify, I can build the process successfully. The question is about installing the example project directly on a device (though I'm thinking emulator won't work either).
I developed a module about two years ago that allowed bluetooth connectivity on Android. I believe the latest version of the Titanium SDK at the time was around 2.0. I believe the specifics of the module and the example app are irrelevant to this question. I will ask my question first, and then try and explain the steps that I have gone through to lead me to the actual question.
My question is: is something in my environment misconfigured, or is this a bug in the Titanium SDK?
If it is the latter, I am very surprised that I can't find any information about it, since it prevents android modules from installing with ant in the latest SDK.
Information about my build environment:
Mac OS 10.9.5
Titanium Studio 3.3.0.GA
Ti CLI 3.3.0
Android 19
java -version: java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
I am trying to build it now for the latest SDK, 3.3.0 at the time of this writing. I found that when I tried to build (install) with ant, it resulted in the following output:
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:133: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:148: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DialogWhenLarge'.
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:159: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
[exec] [ERROR] Error generating R.java from manifest
[exec] [ERROR] Build Failed.
BUILD SUCCESSFUL
Total time: 20 seconds
Not only that, but when creating a brand new mobile module project, and building straightaway with ant:
cd proj/android && ant install
The errors are the same. I should also point out that I reformatted not too long ago, so I find it unlikely that I have borked my titanium installation already. Now, from here, I've gotten into the Titanium build scripts to try and figure out what is happening. First, from the Titanium SDK 3.3.0 release notes:
Due to the addition of the appcompat library, there are a number of behavior changes to the application:
...
The target SDK must be set to API level 14 (Android 4.0.x) or higher, or you must have API level 14 or higher installed.
Now in the build output for my project:
[exec] [TRACE] Writing out AndroidManifest.xml
[exec] [DEBUG] /path/to/my/androidsdk/build-tools/17.0.0/aapt package -m -J /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/gen -M /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/AndroidManifest.xml -S /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res -I /path/to/my/androidsdk/platforms/android-10/android.jar
Note that it's using the tools for android-10 and not android-14+ which is strange considering the relevant bits of my timodule.xml and build.properties:
timodule.xml:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<tool-api-level>19</tool-api-level><!-- deprecated - see below -->
build.properties:
titanium.platform=/Users/trey/Library/Application Support/Titanium/mobilesdk/osx/3.3.0.GA/android
android.platform=/Users/trey/sdk/android-sdk-macosx/platforms/android-19
google.apis=/Users/trey/sdk/android-sdk-macosx/add-ons/addon-google_apis-google-19
android.ndk=/Users/trey/sdk/android-ndk-r9d
As it turns out, it seems to be only the deprecated element that matters, and not in timodule.xml at all. Build scripts are found at $titanium_sdk/$os/$version/android/
Observation: Setting MIN_API_LEVEL = 19 (or 14) instead of 10 in builder.py fixes the issue. So the build script is ignoring my configuration and using the default. This seems to happen in the init method of the builder class:
temp_tiapp = TiAppXML(self.project_tiappxml)
if temp_tiapp and temp_tiapp.android:
if 'tool-api-level' in temp_tiapp.android:
self.tool_api_level = int(temp_tiapp.android['tool-api-level'])
tool_api_level_explicit = True
This sets the tool_api_level that the build script uses, but in my case it never gets called because there is not tiapp.xml. So I made a tiapp.xml, and put it in my example project. It has the same configs as the timodule.xml. As part of the build process this gets copied along with the rest of the example project into a temp folder that will be used to build and run the project. self.project_tiappxml in the code above is the root of the project. And there is still no tiapp.xml there, because it was copied to the Resources directory with everything else, so tool_api_level always gets set to the default of 10. That is basically as far as I've gotten.
So, again my question: is my configuration wrong, or is this a bug. It seems to me that if it is a bug, then no one would be able to build android modules, best I can tell. So if it's my fault, what have I done to cause it, and how can I fix it.
Update: If you saw my last edit, that was wrong and I'm sorry - my selected SDK for ti was 3.2.3! Fixed that and it creates the new project fine. It also builds. However, installing the example project still results in the same error as above:
[exec] [ERROR] Error generating R.java from manifest
[exec] [ERROR] Build Failed.
I also added a line above the call to aapt, to clarify that these errors occur while trying to write AndroidManifest.xml for the example project.
Its good you are working with 3.3.0, because from this version Android module creation is relatively easy.by viewing your build.properties i think something is missing or you forgot to add completely here it should be something close to :
titanium.platform=/Users/xxxxxx/Library/Application Support/Titanium/mobilesdk/osx/3.3.0.GA/android
android.platform=/Users/xxxxxx/Documents/adt-bundle-mac/sdk/platforms/android-16
google.apis=/Users/xxxxxx/Documents/adt-bundle-mac/sdk/add-ons/addon-google_apis-google-16
android.ndk=/Users/xxxxxx/Documents/android-ndk
but what i would suggest is check the following things as they get missed often:
you should have android-ndk installed and in the path
you must have gperf installed with your system(for mac comes with xcode command line tools)
Followed by running the following command in your terminal:
ti create -p android -t module -d <WORKSPACE_DIR> -n <MODULE_NAME> -u <MODULE_URL> --id <MODULE_ID>
## Sample Command
ti create -p android -t module -d ~/Documents/Sample_Workspace/ -n calc -u http:// --id org.appcelerator.calc
If everything is alright you will have a module in your Sample_Workspace folder with name calcand the given id.
you can work on it directly by importing it to your eclipse. and once done can build it using ant over the directory.
Hope it helps. Check the module creation guide.

Cannot build project for iOS from cordova cli

I've created a project using Cordova CLI, version 3.5.0.
I've successfully deployed the project for Android platform by using the CLI.
cordova run android
However, I'm having problem to deploy the project for iOS.
cordova run ios
I encountered this error:
mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Info.plist
mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Prefix.pch
shell.js: internal error
Error: EINVAL, invalid argument '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS.xcodeproj'
at Object.fs.renameSync (fs.js:543:18)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:495:8
at Array.forEach (native)
at Object._mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:471:11)
at Object.mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:1491:23)
at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:126:27)
at pbxProject.EventEmitter.emit (events.js:98:17)
at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/xcode/lib/pbxProject.js:30:18)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at handleMessage (child_process.js:322:10)
This problem only occur after I access the Xcode project manually to add the Icon & splash screen since the icon & splash screens are not automatically added to the project even though declared in config.xml.
I've tried to remove the Info.plist & Prefix.pch file, but then this error appeared.
Error: ENOENT, no such file or directory '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MYPKS-Info.plist'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Object.exports.parseFileSync (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/plist-with-patches/lib/plist.js:18:19)
at Object.module.exports.update_from_config (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:66:31)
at Object.module.exports.update_project (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:189:21)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:113:31
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
The project works just fine if launched from Xcode, but I no longer can build the project from CLI or launch the "serve" command from CLI for debugging purpose.
Please guide me, thanks.
SOLVED
Solved by renaming the project name using Xcode. Thanks Jason for the tips.
Just remove the platforms and then add them again.
cordova platform rm ios
cordova platform rm android
cordova platform add ios
cordova platform add android
EDIT: Try this other solution first! It works for most issues: https://stackoverflow.com/a/28300528/1250444
I struggled with this as well. Finally found a solution by trial and error. D:
What happened for me was renaming the project name to have capitals. This caused all sorts of confusion for Cordova.
The first thing I did was rename the problematic plist and pch files to match the correct capitalization. So, in your case, if it was myPKS, but now is MyPKS, you'd need to rename the files to be MyPKS-Info.plist and MyPKS-Prefix.pch.
I then had to rename the .xcodproj to match capitalization.
After that, another issue happened:
xcodebuild: error: The project 'NewName.xcodeproj' does not contain a target named 'NewName'.
To solve this, I had to rename the target to have the proper capitalization as well. Since I'm new to iOS dev, I have not idea how to describe how to get there. I just finally stumbled upon it, made the change, and it worked!
Best of luck!
What solved my problem was by doing the following
Removing the ios platform; ionic platform remove ios
Removing the android platform; ionic platform remove android
Adding the Ios platform back; ionic platform add ios
Adding the android platform back; ionic platform add android
Rebuild; ionic build
Hope this helps anyone else.
Jason Cox's answer helped me - but I did not rename any files, I just had to change the name of the app in my config.xml
<name>myApp</name>
to
<name>MyApp</name>
This worked in Meteor 1.3.x
Remove a particular platform and re-add again via meteor command via console.
For ex.
meteor list-platforms
meteor remove-platform ios
meteor add-platform ios
I got this same error. The reason why this happen to me was because i changed the name in the xml from myapp to MyApp. It worked again once i changed it back to the old name.
Renaming in xcode also worked so thanks for that.

getting error during project creation using phonegap-2.5.0

i have installed android sdk and downloaded the latest version of phonegap 2.5.0 in fedora 18.
i am trying to create a project using the following command
./create ~/Desktop/android-project com.example.android android_project
am getting the following error.
which: no android in (/sbin:/bin:/usr/sbin:/usr/bin)
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
need your valuable suggestions.
finally found the answer
After checking my .bash_profile paths, and a bunch of digging, I finally found the cause of the issue. If you open up the create file (phonegap-2.5.0/lib/android/bin/create), there is a line that lists ANDROID_BIN=”${ANDROID_BIN:=$( which android )}”. The “which android” is the cause of the issue (or at least it seemed to be in my case). If you replace this line with the full path to your android tools (as listed below) it should resolve the issue. My final line looked like this:
ANDROID_BIN=/Users/ktyacke/DEV/adt-bundle-mac-x86_64-20130219/sdk/tools/android
The message you have means the phonegap script cannot find the android binary, which is included in the SDK you downloaded. Add the binary's directory, as well as the android tool's directory, to your path defined in ~/.bash_profile or any other location you're initializing the shell's environment variables.

How to build Android NDK sample: "bitmap-plasma"

I am trying to build the bitmap-plasma sample that is included with the ndk, but getting an error. I run ndk-build from the samples/bitmap-plasma directory, and the error it displays is that it cannnot locate android/bitmap.h file.
How do i direct the ndk-build script to the file it needs?
Using android-ndk-r4 on Ubuntu Lucid 10.04
Well it's working now, so in case anyone was having my same problem:
There as an android-ndk-r4b bugfix release today, which it seems no longer has this problem.
Available to download here.
http://developer.android.com/sdk/ndk/index.html
With Ubuntu 10.04 and NDK r5b, I have just posted a bug report (with the fix included) for build_platforms.sh. See http://code.google.com/p/android/issues/detail?id=15180 for details. Essentially, the local declarations in the symlink routine must be amended. Otherwise, it only links the first file (alphabetically) from each directory, and truncates the remainder from the list.
Correcting this allowed the symbolic links to be fully populated, thereby filling in the missing header files and libraries and allowing the samples to build successfully.

Categories

Resources