Issue with running application development with Android Studio

Asked 2 years ago, Updated 2 years ago, 21 views

When running the Android app, the main screen has two buttons, and the total activity is about 8. The capacity of the application is about 5mb, but it takes about 7 seconds for the main screen to appear when the application is launched. I'd appreciate it if you could tell me why.

android

2022-09-22 14:56

1 Answers

I wrote about two cases that could occur because the method of measuring the time of 7 seconds is unclear.

[When it takes 7 seconds to see the activity on the screen after clicking the app icon]

Touch the screen in the middle of 7 seconds. If you do not respond to user input such as touch for more than 5 seconds, Android will generate ANR. If ANR occurs, it means that there is a code blocking the main thread, and if it is a code that runs for about 7 seconds, it is not difficult to find. And if you take a closer look at the logcat when you run the app, you can see the following logs.

I/ActivityManager( 1097): Displayed com.example.myapp/com.example.myapp.activity.TutorialActivity: +850ms (total +1s503ms)

The values at the end of the log above show how long it takes to start an activity. Alternatively, you can measure time by putting logs directly into the activity lifecycle function.

[When the time to see the activity is 7 seconds from Android Studio to Run]

This is a normal case. The build time and the time to install the app on the device. Depending on the amount of code, it may take more than a minute. If you're using the latest version of Android Studio, you can expect overall speed improvement by enabling Instant Run. Please refer to the link below for more information.


2022-09-22 14:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.