The Ionic application functions flawlessly on the browser, but unfortunately, it is not performing well on my Android device

My ionic application works well in Chrome, but after generating the .apk file, it encounters issues. In Chrome's developer mode, there is a warning:

SVG's SMIL animations (<animate>, <set>, etc.) are deprecated and will be removed. Please use CSS animations or Web animations instead.

Some important details:

  1. I am only using ng-cordova plugin and Google Maps.
  2. I use TypeScript for development.
  3. I followed the steps at http://ionicframework.com/docs/guide/publishing.html to generate the .apk file.

After installing the application on an Android device, it runs but only displays my parent view:

The index.html file serves as my parent view:

<!DOCTYPE html> <html> <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <!-- Ionic/AngularJS dependencies -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.js"></script>
    <script src="cordova.js"></script>
    <script src="http://maps.google.com/maps/api/js?key=My_Api_Kei"></script>
    <script src="my_apps_js"></script>
</head>

<body dir="rtl" ng-app="appName">
    <ion-nav-view animation="slide-right-left"></ion-nav-view>
</body>
</html>

This section contains my run and config functions:

export var ehmcoModule = angular.module('ModuleName', ['ionic', 'ngCordova']); 

ehmcoModule.run(function($ionicPlatform: ionic.platform.IonicPlatformService) {
    $ionicPlatform.ready(function() {

        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);
        }
        
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
    });
});

ehmcoModule.config(function($stateProvider: ng.ui.IStateProvider, $urlRouterProvider: ng.ui.IUrlRouterProvider) {
    $stateProvider
        .state('app', {
            url: '/app',
            abstract: true,
            templateUrl: 'templates/menu.html',
            controller: Controllers.EhmcoController.controllerName
        })
    
        .state('app.home', {
            url: '/home',
            views: {
                'menuContent': {
                    templateUrl: 'templates/home.html',
                    controller:Controllers.HomeController.controllerName
                }
            }
        })

        .state('app.category', {
            url: '/category',
            views: {
                'menuContent': {
                    templateUrl: 'templates/category.html',
                    controller:Controllers.CategoryController.controllerName
                }
            }
        });

    $urlRouterProvider.otherwise('/app/home');
});

I suspect this issue is not related to routing since I've added a menu item in the parent view that navigates to the first page (app/home). The navigation occurs, but Angular library fails to load, resulting in the bound values not being displayed.

Answer №1

Finally, I was able to resolve the issue. I encountered an injection problem in controllers while working with TypeScript. Everything seemed fine in the browser, but once I generated the APK file, things started to malfunction. To identify and address such issues, one helpful step is to use the 'ng-strict-di' directive:

 <body dir="rtl" ng-app="Ehmco" ng-strict-di>
    <ion-nav-view animation="slide-right-left"></ion-nav-view>
  </body>

In addition, by enabling USB debugging mode on our device, we can execute our application using the following command:

ionic run --device   

or

ionic cordova run --device android
ionic cordova run --device ios

Subsequently, in

chrome://inspect/#devices 

We have the ability to debug our application and identify any issues.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to access information from a SQLite database using Angular

I am a beginner in front-end/back-end communication and I need guidance on how to retrieve data from a SQLite db file to populate a page in my Angular project. I have no idea where to begin, so any resources you can recommend would be greatly appreciated. ...

I'm having trouble getting the JADE tag to render in Express script. Can anyone help me

I am trying to include client-side script in my JADE template and so far I have: extends layout script. function collect_data() { var transitions = {}; $( ":checkbox:checked" ).each(function (index, element) { //// some code ...

Using ThreeJS to Load a Texture from an ArrayBuffer in JavaScript

If I have a JavaScript ArrayBuffer containing binary image data along with the image extension (such as jpg, png, etc), I want to create a ThreeJS Texture without the need for an HTTP request or file load as I already have the binary information. For exam ...

What is the best way to leverage an existing user database and integrate user authentication into a fresh project?

I have recently taken on the task of revamping an established project by creating a brand new frontend from scratch. After careful consideration, I have opted to develop a straightforward Vue/Node.JS project. Within the current framework lies a Postgres d ...

Why is it that the form consistently comes back as invalid?

I populated my edit form inputs with data from an API response, https://i.sstatic.net/2HUpr.png When I click on Continue, the validate() function is triggered. validate() { this.$refs.form.validate() console.log('this.$refs.form.va ...

What is the best way to pass the value of a variable from a controller to a config function

My code... Config function config.$inject = ['$routeProvider', '$locationProvider']; function config($routeProvider, $locationProvider ) { $routeProvider .when('/', { controller: 'LoginControll ...

The React MUI Tab component triggers a re-render and clears the states of its child components

In our endeavor to create a Tab Page using React MUI, we aim for each Tab to contain a child component. While there are no issues when adding these child components individually to a page without tabs, problems arise when incorporating them within the Tab ...

Encountering an unexpected token error while using JSON.parse()

When attempting to parse this JSON string, I encounter an error indicating an unexpected token $scope.feeds = JSON.parse('[{"id":"212216417436_10152811286407437","from":{ "category":"Movie","name":"The Lord of the Rings Trilogy","id":"212216417436"}, ...

Exploring Facebook Graph API response with Angular 2 Mapping

I am using HTTP calls to access the Graph API in order to retrieve posts from a Facebook page. Here is the code snippet that fetches an array of posts: let url = 'https://graph.facebook.com/15087023444/posts?fields=likes.limit(0).summary(true),comme ...

Filtering in AngularJs with multiple select options

I am curious about how to create a filter with multiple options. I have a grid with specific settings and column definitions as shown below: $scope.gridOptions = { enableHorizontalScrollbar: 1, enableFiltering: true, p ...

Is there a way to send multiple parameters in an array to a route?

I am working on deleting multiple rows from a MySQL database using checkboxes in my ejs view with node.js and React app. I have successfully deleted a single row, but I am struggling to figure out how to pass an array of parameters for deleting multiple ro ...

"Clicking on the dropdown menu will consistently result in it collapsing

When it comes to a DropDown menu, the typical expectation is that when an option is selected, the menu will collapse. However, in my situation, I do not want the dropdown menu to collapse if the user is attempting to log in and clicks on the Username and P ...

The identity of the property cannot be located within undefined

<ion-content padding> <ion-list> <ion-item> <ion-label fixed>Username</ion-label> <ion-input type="text" value="" (ngModel)]="userData.username"></ion-input> </ion-item& ...

Tips for triggering useEffect just once when various dependencies are updated simultaneously

Currently, I have implemented a useEffect hook with two dependencies in the following way: useEffect(() => { ..... }, [apiData, currentMeasurements]); It's important to note that the apiData is fetched using useLazyQuery from apollo/client. Upon ...

Encountering 'undefined' issue with find operation in mongoDB

Seeking assistance to utilize all available values in my code. bericht.find({ room: room }).toArray(function(err, docs) { assert.equal(err, null); str2 = str2 + docs.message; The function I'm using can successfully loca ...

Configuring RingoJS to search for necessary modules within the node_modules folder

Currently, I am in the process of transitioning a service from nodejs to ringojs. My main hurdle involves the usage of require(). To illustrate, take a look at this snippet: var restify = require('restify'); The issue arises when RingoJS is una ...

Comparing various object fields to a single input value in JavaScript

I have a challenge with filtering a large dataset of products based on user input values. Here is an example of my product dataset: const products = [ {id: 0, name: "Product1", brand: "Theraflu", itemCode: "THE110", price: 5 ...

Typescript declaration specifies the return type of function properties

I am currently working on fixing the Typescript declaration for youtube-dl-exec. This library has a default export that is a function with properties. Essentially, the default export returns a promise, but alternatively, you can use the exec() method which ...

Slate Map by Google Navigation

I have a situation here that is similar to the grey maps, except all the buttons are visible. Everything appears normal except for the Map tiles, which are all grey! It's strange because it loads nicely at zoom level 8 and then zooms in to the maximum ...

What is the most effective method for transferring items between arrays in JavaScript?

In my situation, I am dealing with two arrays - 'objects' and 'appliedObjects'. My goal is to find an elegant solution in Javascript and/or Angular for transferring objects from one array to another. Initially, my approach was as follo ...