Ionic Again Buld the Same Project Andoroid Studio

Android Development

This guide covers how to run and debug Ionic apps on Android emulators and devices using Capacitor or Cordova. Android apps tin can exist developed on Windows, macOS, and Linux.

Android Studio is the IDE for creating native Android apps. It includes the Android SDK, which will demand to be configured for use in the command line.

Android Studio is besides used to create Android virtual devices, which are required for the Android emulator. Ionic apps can also be launched to a device.

note

Nosotros don't recommend using Android Studio for developing Ionic apps. Instead, it should only really be used to build and run your apps for the native Android platform and to manage the Android SDK and virtual devices.

Installing Android Studio

Download Android Studio from the Android website. More detailed installation instructions can exist found in the User Guide.

Installing the Android SDK

Once installed, open Android Studio. The IDE should detect that the Android SDK needs to be installed. In the SDK Components Setup screen, end installing the SDK. Keep notation of the Android SDK Location.

Android Studio SDK Setup

By default, the latest stable SDK Platform is installed, which includes a drove of packages required to target that version of Android.

To install system images and other minor SDK platform packages, yous may need to ensure Show Packet Details is checked at the lesser of the SDK Managing director. Android Studio SDK Manager

For future reference, the Android SDK can be managed with Android Studio in the Configure » SDK Manager menu of the Android Studio welcome screen or Tools » SDK Managing director within Android projects.

Configuring Command Line Tools

The Android SDK ships with useful command-line tools. Before they can exist used, some environment variables must be set. The post-obit instructions are for macOS and Linux. For Windows, check the documentation on setting and persisting surround variables in terminal sessions.

In ~/.bashrc, ~/.bash_profile, or similar shell startup scripts, make the following modifications:

  1. Set up the ANDROID_SDK_ROOT environment variable. This path should be the Android SDK Location used in the previous department.

                                                          $                                        export                                                            ANDROID_SDK_ROOT                    =                    $Dwelling house                    /Library/Android/sdk                    
  2. Add the Android SDK control-line directories to PATH. Each directory corresponds to the category of control-line tool.

                                                          $ # avdmanager, sdkmanager                    
    $ export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
    $ # adb, logcat
    $ export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
    $ # emulator
    $ consign PATH=$PATH:$ANDROID_SDK_ROOT/emulator

    note

    For apksigner and zipalign, $ANDROID_SDK_ROOT/build-tools<version> must also exist added to PATH.

Creating an Android Virtual Device

Android Virtual Devices (AVDs) are blueprints that the Android emulator uses to run the Android OS. The following documentation is a quick way to get the Android emulator set. For more detailed instructions and information, see the Android documentation.

AVDs are managed with the AVD Manager. In the Android Studio welcome screen, click Configure » AVD Managing director. The AVD Manager tin as well be opened within Android projects in the Tools » AVD Manager carte du jour.

AVD Setup

Click Create Virtual Device and select a suitable device definition. If unsure, cull Pixel ii. Then, select a suitable system image. If unsure, choose Pie (API 28) with Google Play services. See Android version history for information on Android versions.

Once the AVD is created, launch the AVD into the Android emulator. Keeping the emulator running is the best mode to ensure detection while developing Ionic apps for Android.

Android Emulator Booting

Set an Android Device

Actual Android hardware tin can also be used for Ionic app development. But first, the device must be ready for development. The following documentation is a quick fashion to ready Android devices for development. For more detailed instructions and information, see the Android documentation.

  1. Enable USB debugging on the device. Open Settings, navigate to Developer options, and enable USB debugging. The Developer options menu may demand to be enabled get-go. See the Android documentation for instructions.
  2. Ensure the device has permission to connect to the computer. For macOS, no boosted setup is required. For Windows, install the OEM USB drivers.

Verify the connection works by connecting the device to the figurer with a USB cablevision and using the following command:

The device should be listed. Come across the total adb documentation for troubleshooting and detailed data.

Additional setup is required for Cordova to back up programmatic builds. This department is not necessary for Capacitor.

Java

Native Android apps are compiled with the Coffee programming language. Download JDK8 from the download page.

note

Unfortunately, Cordova is not compatible with the latest version of Java.

Gradle

Gradle is the build tool used in Android apps and must be installed separately. See the install page for details.

Before apps can exist deployed to Android simulators and devices, the native projection must be configured.

  1. Generate the native project, if it does not already exist.

    For Capacitor, run the following:

                                                          $ ionic capacitor                                        add                                          android                    

    For Cordova, run the following:

                                                          $ ionic cordova prepare android                    
  2. Set the Package ID.

    For Capacitor, open up the capacitor.config.json file and change the appId property.

    For Cordova, open the config.xml file and modify the id attribute of the root element, <widget>. Meet the Cordova documentation for more data.

Capacitor uses Android Studio to build and run apps to simulators and devices.

  1. Develop the Ionic app and sync it to the native project.

    With each meaningful change, Ionic apps must be built into web avails before the change can appear on Android simulators and devices. The spider web avails and so must exist copied into the native project. Luckily, this process is fabricated like shooting fish in a barrel with a single Ionic CLI command.

                                                          $ ionic capacitor copy android                    
  2. In Android Studio, click the Run button and then select the target simulator or device.

Android Studio Run Button Area

Live reload

To beginning a live-reload server run the following command.

                                          $ ionic capacitor run android -l --host                =                YOUR_IP_ADDRESS                

When running on a device brand sure the device and your evolution automobile are continued to the same network.

The Ionic CLI can build, copy, and deploy Ionic apps to Android simulators and devices with a single command. It can also spin upwardly a development server, like the 1 used in ionic serve, to provide live-reload functionality.

Run the post-obit to beginning a long-running CLI process that boots up a live-reload server:

                                          $ ionic cordova run android -l                

Now, when changes are made to the app's source files, spider web assets are rebuilt and the changes are reflected on the simulator or device without having to deploy once more.

One time an app is running on an Android device or emulator, information technology tin be debugged with Chrome DevTools.

Using Chrome DevTools

Chrome has web developer tool support for Android simulators and devices. Become to chrome://inspect in Chrome while the simulator is running or a device is connected to the computer and Inspect the app that needs to be debugged.

notation

Make sure your application is running on the device or simulator, or information technology will not bear witness up in the list.

Android Chrome DevTools

Viewing Native Logs

If running with Android Studio, native logs can exist constitute in Logcat.

note

If the Logcat window is hidden, yous tin can enable it in View » Tool Windows » Logcat.

Android Studio Logcat

You can likewise access Logcat with ADB.

gloversnack1996.blogspot.com

Source: https://ionicframework.com/docs/developing/android

0 Response to "Ionic Again Buld the Same Project Andoroid Studio"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel