Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
3.1.0
-
None
-
None
-
$ uname -a
Linux HP-Pro 3.2.0-39-generic-pae #62-Ubuntu SMP Wed Feb 27 22:25:11 UTC 2013 i686 athlon i386 GNU/Linux
Description
I'm new to Cordova and I'm trying to add android platform to my app, but it fails:
$ cordova create myapp com.example.asd myapp
Creating a new cordova project with name "myapp" and id "com.example.asd" at location "/home/user/Scaricati/android/eclipse/alternativeworkspace/myapp"
$ cd myapp
$ cordova platform add android
Checking Android requirements...
Creating android project...
Preparing android project
{ [Error: ENOENT, no such file or directory '/home/user/Scaricati/android/eclipse/alternativeworkspace/myapp/platforms/android/src/com/example/asd']
errno: 34,
code: 'ENOENT',
path: '/home/user/Scaricati/android/eclipse/alternativeworkspace/myapp/platforms/android/src/com/example/asd',
syscall: 'readdir' }
It tries to reach an invalid path.
I tried to investigate the issue and I found out that in src directory package name is handled incorrectly:
$ ls platforms/android/src
comundefinedexampleundefinedasd
As you can see dots (".") are replaced by "undefined".
By the way simply renaming the directory didn't solve the issue.
Strangely cordova successfully handles package-name in other places:
$ grep -ri com.example.asd .
./www/config.xml:<widget id="com.example.asd" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
./platforms/android/res/xml/config.xml:<widget id="com.example.asd" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
./platforms/android/AndroidManifest.xml:<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="com.example.asd" xmlns:android="http://schemas.android.com/apk/res/android">
./platforms/android/assets/www/config.xml:<widget id="com.example.asd" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
./platforms/android/src/comundefinedexampleundefinedasd/myapp.java:package com.example.asd;
./.cordova/config.json:{"id":"com.example.asd","name":"myapp"}
My cordova version is
$ cordova --v
3.1.0-0.2.0
This issue affects "non-cli" Cordova either (I tried to make it work in eclipse).
Thanks in advance for your help.
EDIT:
I'm replying to myself because I've edited manually sources and I think I removed the bug.
line 128, ~/.cordova/lib/android/cordova/3.1.0/bin/lib/create.js
var package_as_path = package_name.replace(/\./g, path.sep);
path.sep is undefined. I just replaced it with path sep of my os
var package_as_path = package_name.replace(/\./g, '/');
It seems to work normally now.