Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-5143

CLI cordova prepare fails to copy the common files to android platform



    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0
    • Fix Version/s: None
    • Labels:
    • Environment:



      I had created a CLI project, and then used CLI to add the android platform and add many plugins, etc.

      Then I used cordova prepare to copy my "common" www files to the android platform folders. This step worked OK for the simple HelloWorld example from the CLI online guide, but for my full CLI project the prepare did not copy anything. The prepare processed the plugins OK, but nothing copied, and there was no error or any other indication what went wrong. (The -d debug flag did not help much either)

      Eventually, after consuming a lot of coffee the problem was isolated to a file called android_parser.js which executes during the cordova prepare processing.

      This code...

      var orig_java_class = fs.readdirSync(orig_pkgDir).filter(function(f) {return f.indexOf('.svn') == -1;})[0];

      is apparently assuming that the main app java class is the only (or first?) file found in the package directory. But this assumption is incorrect for my project (e.g. there are other sub-packages which were found ahead of the .java file) and so the script was failing shortly after this line of code, resulting in no copy...

      For example, my project structure resembles

      \-- com
          \-- fujitsu
              \-- mypkg
                  \-- apkg1
                  \-- bpkg2
                  \-- zpkg3

      To get arround this issue I am currently using using a hacky workaround - renaming the app java file with a prefix "AAA_" so that at least the zero offset can find it OK.

      \-- com
          \-- fujitsu
              \-- mypkg
                  \-- apkg1
                  \-- bpkg2
                  \-- zpkg3

      With this hack in place the cordova prepare copies the common files as expected.

      BTW - In fact I don't even use this file at all because my AndroidManifest.xml is manually configured to launch a completely different main activity. But I have to leave this dummy AAA_MyApp.java file lying around just so the CLI cordova prepare will behave properly. If not for this issue then I would just delete it.




            • Assignee:
              shepheb Braden Shepherdson
              dinglemouse Peter
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: