You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Giacomo Lombardello (JIRA)" <ji...@apache.org> on 2013/11/05 11:58:17 UTC

[jira] [Updated] (CB-5279) Cordova - can't add android platform - package name is handled incorrectly ("dots" are replaced by "undefined")

     [ https://issues.apache.org/jira/browse/CB-5279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Giacomo Lombardello updated CB-5279:
------------------------------------

    Description: 
I'm new to Cordova and I'm trying to add android platform to my app, but it fails:
{quote}
    $ 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' \}
{quote}
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:
{quote}
    $ ls platforms/android/src
    comundefinedexampleundefinedasd
{quote}
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:
{quote}
    $ 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"\}
{quote}

My cordova version is
{quote}
    $ cordova --v
    3.1.0-0.2.0
{quote}

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.



  was:
I'm new to Cordova and I'm trying to add android platform to my app, but it fails:
{quote}
    $ 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' \}
{quote}
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:
{quote}
    $ ls platforms/android/src
    comundefinedexampleundefinedasd
{quote}
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:
{quote}
    $ 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"\}
{quote}

My cordova version is
{quote}
    $ cordova --v
    3.1.0-0.2.0
{quote}

This issue affects "non-cli" Cordova either (I tried to make it work in eclipse).

Thanks in advance for your help.






> Cordova - can't add android platform - package name is handled incorrectly ("dots" are replaced by "undefined")
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: CB-5279
>                 URL: https://issues.apache.org/jira/browse/CB-5279
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CLI
>    Affects Versions: 3.1.0
>         Environment: $ 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
>            Reporter: Giacomo Lombardello
>            Priority: Blocker
>
> I'm new to Cordova and I'm trying to add android platform to my app, but it fails:
> {quote}
>     $ 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' \}
> {quote}
> 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:
> {quote}
>     $ ls platforms/android/src
>     comundefinedexampleundefinedasd
> {quote}
> 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:
> {quote}
>     $ 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"\}
> {quote}
> My cordova version is
> {quote}
>     $ cordova --v
>     3.1.0-0.2.0
> {quote}
> 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.



--
This message was sent by Atlassian JIRA
(v6.1#6144)