Showing posts with label Hybrid Mobile Apps. Show all posts
Showing posts with label Hybrid Mobile Apps. Show all posts

Saturday, June 8, 2019

How to add slider in flutter



You can add slider in flutter with the help of “intro_slider” plugin. To integrate this please follow below steps -


Add below line in your pubspace.yam file -

dependencies:
  intro_slider: ^2.2.0


Now click on “Package get” option from top section to get this package in your app.




Now, Import below package in your file -

import 'package:intro_slider/intro_slider.dart';


Note - Make sure to add your images in pubspace.yaml file like this -

assets:
  - assets/images/photo_eraser.png
  - assets/images/photo_pencil.png
  - assets/images/photo_ruler.png



Slider images for Android and iOS


Create a new class as below -

import 'package:flutter/material.dart';
import 'package:intro_slider/dot_animation_enum.dart';
import 'package:intro_slider/intro_slider.dart';
import 'package:intro_slider/slide_object.dart';


class TutorialScreen extends StatefulWidget{

  TutorialScreen({Key key}) : super(key: key);

  @override
  TutorialScreenState createState() => new TutorialScreenState();

}


class TutorialScreenState extends State<TutorialScreen>{
  List<Slide> slides = new List();

  @override
  void initState() {
    super.initState();

    slides.add(
      new Slide(
        title: "ERASER",
        description: "Allow miles wound place the leave had. To sitting subject no improve studied limited",
        pathImage: "assets/images/photo_eraser.png",
        backgroundColor: Color(0xfff5a623),
      ),
    );
    slides.add(
      new Slide(
        title: "PENCIL",
        description: "Ye indulgence unreserved connection alteration appearance",
        pathImage: "assets/images/photo_pencil.png",
        backgroundColor: Color(0xff203152),
      ),
    );
    slides.add(
      new Slide(
        title: "RULER",
        description:
        "Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of",
        pathImage: "assets/images/photo_ruler.png",
        backgroundColor: Color(0xff9932CC),
      ),
    );
  }

  void onDonePress() {
    // Do what you want
  }

  @override
  Widget build(BuildContext context) {
    return new IntroSlider(
      slides: this.slides,
      onDonePress: this.onDonePress,
    );
  }

}



Now call this from your main.dart file by using below code -

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: TutorialScreen(),
      debugShowCheckedModeBanner: false
    );
  }
}


This plugin have many options you can check all available options on below urls -



How to change project name in flutter


Solution for Android -

This is very simple in flutter, If you want to change the project name which will display on the mobile app. First, open your project in android studio or in any editor and then navigate to android/app/src/main/AndroidManifest.xml 



After this, you have to change the label value in AndroidManifest.xml  for android:label 

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label=“APP Name”
    android:icon="@mipmap/ic_launcher">


Just replace “APP Name” with your app name. Now run your project in android simulator/device. 
Note - If changes are not updating then please uninstall your existing build and install again.



Solution for iOS - To update app name in iOS you just need to navigate on below location - 

ios/Runner/Info.plist



Now search for “CFBundleName” in Info.plist file and replace its value with your app name. Please check below example - 

<key>CFBundleName</key>
<string>APP Name</string>

Now, Run the app in simulator/Device. This will update your app name.

Note - Same as Android if the app name is not updating then please uninstall your existing build and install again.


This will update the app name for both (Android and iOS). 

Tuesday, March 19, 2019

No toolchains found in the NDK toolchains folder for ABI with prefix: mipsel-linux-android


This error comes due to NDK version mismatch, To resolve this error you have to download an older version of NDK and need to remap NDK path. Then you can build the project successfully. To do this please follow the below steps -

1. First, you need to open the NDK downloader page. You can open by using below URL -
https://developer.android.com/ndk/downloads/

2. Now at the bottom of this page, you can see "older versions of the NDK" and click on "NDK Archives" tag to see all older versions.



3. Agree with the Terms from this page by clicking on "I agree to the terms" button. After this, you can see all older versions of NDk.



4. Download your NDK older version from this list. In my case, it was "Android NDK, Revision 14b".



5. Open Android NDK location directory. You can check location from File -> Project Structure -> SDK location. Check below image for more information -



6. Now, Extract file which you have downloaded and move that folder in toolchains folder - (Or you can delete toolchain folder and past our recent downloaded toolchain on this location)



7. After this, you need to rebuild the project. 



This will resolve your issue. In some case, you can also try below solution -

Open Android Studio and go to File -> Project Structure -> SDK location, uncheck NDK If you do not need this, and then restart android studio. This will resolve your issue.


Please post a comment if you are still having an issue in this. I will try to resolve that issue.

Thursday, February 7, 2019

The sandbox is not in sync with the Podfile.lock in ionic


In my case, I was building an ionic project. This error comes when I try to run the project in iSO. I spend much time to resolve this issue, Some say we can run pod update OR pod install command to resolve this issue. But noting work in my case. Finally, I found the solution for this. This is very simple. Just follow the below steps to resolve the issue -    

1. First Quit your Xcode.
2. Now move in iOS platform folder. (i.e, Project Dir/platforms/ios)
3. Delete Pods folder from here.
4. Delete Podfile.lock from here.
5. Now open ios platform in the terminal and run "pod install" command in terminal. Make sure to run this command without admin (without sudo).
6. Now open your project in Xcode. Note - Open project via .xcworkspace file.

Now build and run the project, If that does not work follow below more steps - 

7. In Xcode, From navigation go to root node and from the Xcode on the right choose 'Build Settings' option.  Check more information in below image -




8. Now scroll down and there should be following entries - PODS_PODFILE_DIR_PATH and PODS_ROOT. If this available please correct the entry and if not available please add the entry by using below details - 


8.1 Click on the plus (+) icon to add the entry and select "Add user-defined settings". Check below image -




8.2 Add "PODS_PODFILE_DIR_PATH" and for both Debug and Release add "${SRCROOT}/." entry.
8.3 Now again add "PODS_ROOT" and for both Debug and Release add "${SRCROOT}/Pods" entry.

After adding the above details it will look like this -





Now try to build your project. It will build successfully. If still, you are facing any issue please post your error in the comment section. I will try to resolve this issue.

Wednesday, January 23, 2019

Show image loader in ionic | html



In above image please check 1,2,3 cases.
Case 1 - Image is not loaded so here loader is showing.
Case 2 - Image is half loaded so still image loader is showing.
Case 3 - Image is fully loaded so loader is not showing.


Solution -

Hey guys, There are many third-party libraries available for this but when I try those libraries nothing working properly. So I found a solution with the help of CSS. This is very simple and easy to use. In this solution, we will show loader git until the image load in img tag. So now check below details for solution -


First, in your CSS file add below class -

.default-img-loader{
  background: url('../assets/img/loader.gif') no-repeat center;
}

This class will add a background image to the image tag. Here we used below property -
url('../assets/img/loader.gif')  - Make sure to update path according to your project.
no-repeat  - This will not repeat image in background.
center - This will place the image in center.


Now, In your HTML (template) file add “default-img-loader” class in image tag.
Eg- 

<img class=“default-img-loader” src=“your image url path of server”>


Note - Gif image size should be 16 × 16 OR 18 × 18 for batter experience. You can download loader from below URL -


Feel free to post a comment if you face any issue during the implementation of this. 



This will help in this case when you are fetching images from server and image size is very long. With the help of this solution, you can show loader until the image fully load. This will work for ionic, HTML, angular, PhoneGap etc. This works for me. I develope ionic app and its working perfect in this.


  

Monday, January 21, 2019

Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle


CordovaError: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle


To solve this issue you have to install gradle. To install gradle please use below steps -

For debian/ubuntu - If your system is a debian/ubuntu then, in this case, you can use below command on the terminal to install gradle. 
sudo apt-get install gradle


For Mac - If your system is a Mac then follow below steps -  

First, download the gradle binary only distribution with the help of this URL - https://gradle.org/gradle-download/
Now open your system terminal and run the following command to unzip the android sdk into the development directory that is under your user home directory
unzip ~/Downloads/gradle-3.1-bin.zip -d ~/Development

To edit base profile open vi editor. We also need to set GRADLE_HOME environment variable 
vi ~/.bash_profile

To enter in edit mode in vi editor hit i and now add below text to .bash_profile
export GRADLE_HOME=~/Development/gradle-3.1/bin

To exit edit mode press Esc key 
To enter in command mode press : (colon key)

To save changes and exit vi editor type wq and press enter key.

To update changes run the following command 
source ~/.bash_profile

Now test this by running below command in terminal 
echo $GRADLE_HOME

For Windows - If your system is a Windows then follow below steps -   
This is a very long process, Here are some steps for windows. Just follow all steps mentioned on below URL -
http://bryanlor.com/blog/gradle-tutorial-how-install-gradle-windows

Sunday, December 16, 2018

Failed to find 'ANDROID_HOME' environment variable



I am getting below error when I am trying to run project -

> cordova build android
Android Studio project detected
(node:15997) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.


To resolve this issue please run below commands in the terminal -

export ANDROID_HOME="/Users/chetandeshmukh/Library/Android/sdk"
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"


How to find the Android SDK path?

First open android studio, Then click on SDK manager. For more info please check below image -



Now select Appearance & Behavior -> System Settings -> Android SDK



 Now copy your SDK location with the help of the above steps and update in command.


This process will set the Android Home path in your system.


Now try once again to run your project. This process will resolve your problem. If you still facing any issue please add your error in the comment section. We will resolve this. 

Thursday, November 8, 2018

ionic interview questions



Ionic interview questions  OR hybrid mobile app interview questions -

1. What is Ionic Framework?
The IONIC framework is an HTML5 platform that allows web developers (UI developer) to build hybrid mobile applications. Hybrid apps are those apps that have all access of native perform functionality and or you can say it is small websites running in browser shell in the application. It is a powerful HTML5 SDK that helps peoples to build mobile apps using HTML, CSS, and JavaScript. Ionic framework mainly focus on the look and feel of the app and its UI interaction. Ionic very fits well with the front end part of your app. It is free to use under MIT license so that it can be used for personal or commercial applications/projects.


2. What are the advantages and disadvantages of building hybrid/mobile applications using the Ionic framework?
The most obvious advantages are:
1. The ionic framework builds hybrid applications using web technologies. It means web developers can very easily build mobile applications too. Also, because it uses JavaScript / angular, almost the same codebase can be used to build both iOS and Android applications.
2. Development cost is less compared to native iOS and Android applications.
3. The ionic framework is excellent for quick application ideas prototyping.
Some of the disadvantages are:
4. It is not suited for high-end graphics dependent applications or games.
5. Performances are not as good as native applications, namely animations, scrolling, and network operations.
6. As mentioned, JavaScript animations are not as performant as native animations. However, there are JavaScript / angular libraries, like chartjs, which provide decent graph UI performance on the devices.


3. Explain what is the difference between "ionic build and ionic prepare” commands?
ionic prepare copies all files from the www folder into the target platform’s www folder.
ionic build also does this but also builds the app’s source code so that it can be run on a simulator/emulator or a device.


4. Explain some of Useful Ionic Commands. 
Please check commands and its description -
1. start-  This command is used to create a new project.
2. serve- This command is used to start a local dev server for app dev/testing.
3. generate-  This command is used to generate pipes, components, pages, directives, providers, and tabs.
4. docs - This command is used to open the Ionic documentation website.
5. build - This command is used to build web assets and prepare your app for any platform targets.
6. link- This command is used to connect your local app to Ionic.
7. info - This command is used to print system/environment info.
8. login- This command is used to log in with your Ionic ID.
9. signup - This command is used to create an Ionic account.
10. upload- This command is used to upload a new snapshot of your app.
11. telemetry-  This command is used to opt in and out of telemetry.
12. config set- This command is used to set config values.
13. config get- This command is used to print config values.
14. cordova compile- This command is used to compile native platform code.
15. cordova build- This command is used to build an Ionic project for a given platform.
16. cordova emulate- This command is used to emulate an Ionic project on a simulator or emulator.
17. cordova plugin - This command is used to manage Cordova plugins.
18. cordova platform- This command is used to manage Cordova platform targets.
19. cordova resources - This command is used to automatically create icon and splash screen resources.
20. cordova prepare - This command is used to copies assets to Cordova platforms, preparing them for native builds.
21. package download- This command is used to download your packaged app.
22. package build- This command is used to start a package build.
23. package list - This command is used to list your cloud builds.
24. cordova run - This command is used to run an Ionic project on a connected device.
25. package info - This command is used to get info about a build.


5. How to use service/providers in Ionic?
Services play a very important role in Ionic as you already know they provide information to our application and perform various tasks for us. SimpleAlert, data, ConnectivityMonitor, GoogleMaps, etc. are some of the services which are built in ionic framework. There are a few points which are to be kept in mind while creating a service. Adding a provider to it, Importing a service and injecting it is the most important thing. The services should be imported into the classes where they are going to be used. When it is injected inside a constructor, a new member variable is created which can be accessed from anywhere within the class. A provider can be added in a service by two ways - Either it can be added to an individual component, or it can be added globally to the application when bootstrapping the root component.


6. Explain the difference between PhoneGap, Cordova, and Ionic?
PhoneGap is a library that exposes native mobile phone functionalities as JavaScript API. When Adobe purchased PhoneGap, its open source core was donated to the Apache Software Foundation under the name Cordova. In the beginning, there was almost no difference between Cordova and PhoneGap. Although, over the years of development, Adobe started adding a proprietary set of the services to PhoneGap. Today, it is safe to say PhoneGap is Cordova plus extra Adobe services. Ionic uses Cordova, not PhoneGap for its core tools. Beside native mobile phone functionalities, Ionic gives structure and code scalability to JavaScript applications by using AngularJS. It also provides a set of Angular directives and components to speed up application development.


7. How to use observables in an Ionic framework?
Observables are something that is not specific to Ionic or Angular. It is provided by the RxJS library. Observables are almost similar to the promises but can do a lot more. It can deal with multiple values at a time rather than just resolving one value. You can even subscribe to an observable to manipulate the data which is associated with it. Observables are considered to be “lazy”, i.e. they won’t get executed until and unless they are subscribed to. Various operations can be applied to the observables for modifying it and returning a new one. You can even create your own observable. The observable patterns are combined into one with the help of the subject which is preferred for simple implementations.


8. What is Ionic Market?
The ionic market provides ready starter, plugins, themes etc. for the developer to download them and use for their own projects.


9. How do you persist data between application launches using the Ionic framework?
As Ionic behind the scene builds HTML5 based applications, you can use localStorage and sessionStorage API to persist data on the mobile phone. However, since localStorage can only store strings, objects need to be stringified before saving. Also, it is important to mention localStorage has size limit around 5MB.


10. How do you pass data from one view to another in Ionic applications?
You can use the NavController and NavParams to send data to pages that you push


11. Give some examples of hybrid mobile app frameworks?
re are several frameworks are available for hybrid mobile app development.

Mobile Angular UI
Intel XDX
PhoneGap
Ionic
Appcelerator Titanium
Kendo UI


12. How can you render a 5000 item list in Ionic, without affecting scroll performance?
Ionic provides a collection-repeat directive that renders only visible items in the DOM. So even if the list is huge, like 5000 in our example, only items visible in a viewport are rendered. Thus, scroll performance is not affected.


13. How To Generating New Pipes, Tabs, Components and Pages using Ionic 3 and Angular 4?
Ionic 3 CLI Commands For Angular 4 Projects
1.     Pipes,
2.     Providers and
3.     Directives,
4.     Components,
5.     Tabs

Syntax –
-        ionic generate [pipes] [pipes-name]
-        ionic generate [providers] [providers-name]
-        ionic generate [directives] [directives-name]
-        ionic generate [components] [components-name]
-        ionic generate [tabs] [tabs-name]

Example –
-        ionic generate pipe
-        ionic generate provider
-        ionic generate directive
-        ionic generate component
-        ionic generate tabs
-        ionic generate page

-        ionic generate component demoApp
-        ionic generate page Login
-        ionic generate page register --no-module
-        ionic generate page users --constants
-        ionic generate pipe MyCustomPipe


14. What is the advantage of caching the views in Ionic apps? Provide examples.
Ionic by default caches up to ten views, which improves performance and also maintains different states in the views at the same time. For example - The cache can maintain scroll position in the views or active state of buttons.


15. What is the difference between native mobile app design and responsive web design? Do we really need both? Explain.
Mobile apps can be developed natively or as hybrid apps, while mobile-friendly websites can be developed as adaptive or responsive. The basic design process behind all of them is more or less the same. The only thing we need to consider when designing for mobile is that we have a specific set of rules we need to follow. Apple has its own, and so does Google.
When you’re designing for iOS or Android, the underlying process is the same. First, we do research that will outline best practices and show us what we can do on a certain platform and what not. Basically, research helps us we learn restrictions and take advantage of possibilities a given field.
Designers are likely to work on both native app and responsive web designs. Native apps are important because we want the user to have them on their dashboard, and this way we want to help users in their everyday activities. Some native apps can work offline while others can’t.
Responsive web design is important for SEO and Google indexing. So, if we want to have your project well-ranked on Google, you definitely go for a mobile-friendly responsive design.


Monday, October 15, 2018

iPhone XR / XS / XS Max CSS media queries



Handling the Notch on iPhone X / XR / XS / XS Max OR iPhone media queries for responsive design  -

Media queries are very useful to modify your website or hybrid apps depending on a device resolution/type. This is very important to manage resolution in different devices. It help us to present batter view of app/website to users. Below are the examples for iPhone XR / XS / XS Max CSS media queries -


/* Apple iPhone XR 1792x828px at 326ppi Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 896px) 
    and (-webkit-device-pixel-ratio : 2) { }

/* Apple iPhone XS 2436x1125px at 458ppi Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) { }

/* Apple iPhone XS Max 2688x1242px at 458ppi Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 896px) 
    and (-webkit-device-pixel-ratio : 3) { }


Below are the examples for iPhone X / 8 / 8 Plus CSS media queries -

/* Apple iPhone X Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) { }

/* Apple iPhone 8 Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 667px) 
    and (-webkit-device-pixel-ratio : 2) { }

/* Apple iPhone 8 Plus Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 736px) 
    and (-webkit-device-pixel-ratio : 3) { }



Note : If you are looking for a specific orientation. Follow below rules -

For portrait orientation add below rule :

    and (orientation : portrait) 


For landscape orientation add below rule :

    and (orientation : landscape) 



Now use above media query in your project. It helps me a lot. If you have any query please post in a comment. 

For other all Media Queries please check this link - https://allexperts16.blogspot.com/2018/06/media-queries-for-standard-devices.html

It has Media Queries for - iPads, iPad 3, iPhone 4, iPhone 5, iPhone 6, iPhone 6+, Samsung Galaxy S3, Samsung Galaxy S4, Samsung Galaxy S5, and many more. 


Wednesday, October 10, 2018

How to remove white space from iPhone X in ionic / Cordova

Hey all,

Please check below image in this you can find this issue -




Finally, I found the solution to this problem. It saves a lot of time. Now UI is proper of my app. Please run below command in your project -

First uninstall "statusbar" old version plugin by using this command -
ionic cordova plugin rm cordova-plugin-statusbar

Now add the new version of this plugin by using this command -
$ ionic cordova plugin add cordova-plugin-statusbar
$ npm install --save @ionic-native/status-bar


Basically, what we did, We just removed the plugin and added new updated plugin of "Status Bar". This solves my problem. Please check this image -







Steps for ionic soluion :

ionic cordova plugin rm cordova-plugin-statusbar
$ ionic cordova plugin add cordova-plugin-statusbar
$ npm install --save @ionic-native/status-bar


Steps for Cordova solution :

cordova plugin rm cordova-plugin-statusbar
cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git