0

I have just start using both Ember and Phonegap and I am using the Ruby on Rails Ember-Rails gem as wanted to use Rails to do the asset pre-compilation. I can use rails s to run the Ember app and all works fine. To get into a phonegap app, I am doing a rake assets:precompile command, then copying the fingerprinted css and js files to an assets directory and modifying the index/html file to pick them up as follows:

<!DOCTYPE html>
<html>
  <head>
    <title>MahimanagerPhoneApp</title>
     <link rel="stylesheet" media="all" href="./assets/application-f82ab2dfef6aa5b0589d092d8949fc1e6126d774e74d5a024c1407a7082732f6.css"/>
     <script src="./assets/application-0df5442d7ea56c8d2a38022448c2c9b57397f561885306bbdfff8db7962547c3.js"></script>
  </head>
  <body>
    <div id="ember-app"></div>
  </body>
</html>

I then copy the index.html and the assets into a phonegap app directory. When I use the phonegap cli to build the app and launch it on on emulator it comes up with "Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)". I have tried the various solutions in this post :Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html) but none resolved my problem. When I open the index.html in a browser I get Uncaught UnrecognizedURLError: /home/paul/Documents/testapp/www/index.html which is coming from somewhere within the ember.js file but I assume this is only because it was loaded from the file system rather than severed from a host.

I have looked into the phonegap-rails gem too, but it looks like the commands it expects to run in phonegap are from an older version and no longer work.

I am not really sure where to go from here, and maybe its just not a good idea to try and do this from rails?

UPDATE: I gave up on trying to get this to work. I have instead gone with the ember-cli-cordova option (https://github.com/poetic/ember-cli-cordova). Which had a few minor stumbling blocks that were all easily solved and now I am up and running....

Community
  • 1
  • 1
mahi-man
  • 3,678
  • 1
  • 23
  • 33

1 Answers1

0

If you change the locationType in your environment.js file to 'hash', rather than 'auto', you will solve this issue.

The issue is that phonegap access your app at a url such as file:///android_assets/www/index.html

ember tries to resolve the index.html as a route when the locationType is set to auto.

l33z3r
  • 615
  • 5
  • 15
  • As per the comment in the update, I have actually moved to ember-cli-cordova but it is still giving me this error on the emulator (but not when I install on an actual phone). I tried changing the location type to hash as you suggested, but it made no difference unfortunately.... – mahi-man Jul 25 '15 at 10:10
  • Ok, could be another factor causing your issue. I just solved the issue by taking those steps. Sorry, I'm out of ideas. – l33z3r Jul 25 '15 at 17:02