Run the App

Source: Internet
Author: User

If you have learned the previous tutorial , then you already have a project containing the default "Hello World" source file, and you can run the application with zero modification immediately.
  
How you run your app depends on two things: whether you have a real Android device, and whether you're using Androidstudio. This lesson shows you how to install and run your app on real-world devices and Android emulators. There are two ways of Androidstudio and command-line tools.

Run your app on real-world devices

If you have an Android device, this will teach you how to run the app on your device.

1. Install your Android device on your computer

1. Through the USB port, the intercom device is connected to your development machine, which is usually a computer. If your computer is running a Windows operating system, you may also need to install a driver that corresponds to your device. Refer to this OEM USB drivers documentation.

2. Turn on USB debugging on your Android device.

    • Most of the 3.2 and older systems, you can find this option from here, settings > Applications > Development.
    • If the system is 4.0 and above, this option is in Settings > Developer options.

  Tip: On the 4.2 and newer systems, the developer options are hidden by default. If you want to open the developer options, you can press 7 words in the settings > about the phone, this option will prompt the developer option has been released. You can then go back to the setup screen and you'll find the developer options.

2. Run the app via Androidstudio
    1. Select a file or folder in your project and click the Run button above the toolbar.
    2. Eject the Choose Device window, select the Choose a running device option button, select your Android device, and click OK.

  At this point, Android Studio has installed the app on your Android device, and it's up and running.

3. Run the app from the command line

Open a command-line window and the CD enters the project root directory. In debug mode, use Gradle to compile your project and invoke Assembledebug build task using the Gradle wrapper (Gradlew assemblerelease) script. This creates an. apk file in the build/directory.

Windows operating system, use the following command:

           > gradlew.  Bat Assembledebug

Mac and Linux platforms, use the following command:
+x Gradlew
./Gradlew Assembledebug
  After the build project is completed, the input apk file is here app/build/outputs/apk/。
提示:   The first line of code for Mac and Linux platforms(chmod)获取chmod权限,只需要在第一次构建当前项目的时候执行就行。

     在保证SDK里面的platform-tools/已经添加为环境变量的情况下,执行:

ADB install app/build/outputs/myfirstapp-debug.apk

On your device, find Myfirstapp, and then open him up. Run successfully.

The above is to build all the tutorials to run Android, want to learn how to develop, continue to look down.

Run the app on the emulator, in the same way as above, just install the device driver here and become the creation simulator, referring to the use of Android development tools (AVD).

Run the App

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.