1

I'm trying to build my first mobile app. What I usying: AngularJS, Mobile Angular UI, jQuery and PhoneGap.

My code:

<!doctype html>
<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-touch.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <link rel="stylesheet" href="/mobile-angular-ui/dist/css/mobile-angular-ui-base.min.css" />
    <link rel="stylesheet" href="/mobile-angular-ui/dist/css/mobile-angular-ui-desktop.min.css" />
    <link rel="stylesheet" href="/css/demo.css" />
    <script src="/mobile-angular-ui/dist/js/mobile-angular-ui.min.js"></script>
</head>
<body ng-app="MyApp" ng-controller="MainController">

   HERE HTML CODE

<script>

   HERE ALL LOGIC

</script>
</body>
</html>

In all browsers all works fine, but when I getting apk file from PhoneGap and running it on my Nexus 4 (Android) I seeing white screen :*(

Bohdan Vorona
  • 685
  • 1
  • 13
  • 26

1 Answers1

2

you need to add the below line at the start of the the head tag

<script type="text/javascript" src="cordova.js"></script>

Also make sure you check the deviceready event to make any native device API calls.

frank
  • 3,180
  • 3
  • 16
  • 18
  • Thanks. I added cordova.js to my project, but now I'm seeing this error: "Uncaught ReferenceError: require is not defined". This is line "var channel = require('cordova/channel')" in cordova.js file. – Bohdan Vorona Jul 27 '14 at 09:39
  • Have look over [here](http://stackoverflow.com/questions/19818282/require-exception-in-cordova-phonegap-project) and [here](http://stackoverflow.com/questions/16149986/phonegap-error-uncaught-referenceerror-cordova-is-not-defined) for the require error.. How did you create the phonegap project? – frank Jul 27 '14 at 09:42
  • another link for phonegap build require error [here](https://github.com/katzer/cordova-plugin-local-notifications/issues/166) – frank Jul 27 '14 at 10:55
  • phonegap build require error link [here](http://stackoverflow.com/questions/23298695/ionic-framework-cordova-camera) – frank Jul 27 '14 at 11:01