Startup error

I recently downloaded Android Studio 2.0 and created a new launcher app and added nothing to the code. After launching the application, Android Studio installs the APK on the emulator successfully, but does not start the application, instead it causes the following error:

$ adb shell am start -n "com.example.muhammad.firstapp/com.example.muhammad.firstapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Unexpected error while executing: am start -n "com.example.muhammad.firstapp/com.example.muhammad.firstapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Error while Launching activity 

I searched it on google and found that it was asked before, but the solution provided does not work for me either. I also did not add anything to the AndroidManifest.xml file.

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.muhammad.firstapp"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

MainActivity.java

 package com.example.muhammad.firstapp; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } 

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.muhammad.firstapp.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </RelativeLayout> 
+17
android android-studio
Apr 22 '16 at 20:14
source share
19 answers

I had exactly the same problem today [Android Studio 2.3.3, Android 8.0 by phone]

This is what I discovered. The application I was trying to install was not shown in the Android application window (the one where you have everything). But as soon as I entered: Settings-> Apps & Notifications-> AppInfo, I could see this screenshot where it was said that this application was "not installed for this user":

enter image description here

At this point, I entered the application → clicked on three dots in the upper right corner → Delete for all users

Now, when I tried to run the project through Android Studio, the error message disappeared and the application was installed correctly

Hope this helps, have a good day
Antonino

+23
Sep 25 '17 at 5:54 on
source share

If you are using Android 2.0+, follow these steps: 1. Go to launch
2. Select edit configurations.
3. Type -r in the Set Flags text box.
4. Apply and OK, and then run the program again

tested (07/23/2016)

+9
Jul 22 '16 at 23:13
source share

I encounter the same problem in AVD when everything is fine the first time you start the application, but when you start the application, the message "Error at startup" appears again.

My permission: in AVD, uninstall apk , maybe the reason is that the new Android studio has problems installing apk in AVD.

Thanks Yu

+3
Jun 09 '16 at 16:03
source share

There is a problem with the ability to instantly launch Studio 2.0+

Run Android Open Source Project - Tracking Issues

Do not waste time reinstalling the studio or cleaning the gradle build file.

Just add the -r flag to Set Flags in Run-> Change Configuration-> General

+3
Jun 12 '16 at 4:05
source share

For me, I was not able to solve a problem that absolutely infuriates for a piece of software as important as this. I am a diehard guy from Android, and this is, frankly, unacceptable, because I can’t even debug the application.

However, I have found a workaround that may help some.

For me, the Session 'app': Error Launching activity did not prevent the installation of the application, but it prevented the debugging of the application, since it was not possible to connect the debugger. However, there is another way.

Launch the application on the phone, then click the attach debugger button to the Android process (next to the regular debug button, it looks the same), this allows you to attach the debugger to the already running application.

This is damn annoying, but at least I can debug my application again.

+2
Sep 23 '18 at 22:11
source share

After long hours of work, I came to the conclusion that the problem is with user files stored in AVD. Whenever I select Wipe Data from AVD , the application works like a charm and does not show an error. But it really hurts for Wipe Data developers every time before launching the application, since Wipe Data will only work if your emulator does not work.

In another test phase, I destroyed the AVD data, and then launched the application, it was successful; but when I tried to run the application a second time, it again shows me this error.

 Error while Launching activity 

Then I opened Application Management and removed my application from the emulator. But that didn't work either.

Bypass

Another workaround (but this does not work for me)

  • Session 'app': Error starting activity

Final conclusion

I think the problem is related to something when we tried twice to launch the “application”. He does not uninstall the previous version of the application, so when he found the package name already there, he does not install the application; leads to an error starting the activity.

+1
Apr 24 '16 at 17:07
source share

I have been working on this exact problem for the last 8 hours ... have you had any problems after rolling back from 2.0 to 1.5.1?

I noticed that even with an error, application launch sometimes stops.

You are not alone, brother. I will definitely be updated when I find out the solution.

Also, what are your specifications? I run the following:

  • Windows 7
  • AMD FX (tm) -8120 8-Core

AVD:

  • Android 6.0
  • CPU / ABI: ARM Google API (armeabi-v7a)
  • Target: lvl 23 API
  • Accelerometer
  • heapSize: 64

If you would like more information, let me know. Sample size 2 is always better than 1.

+1
Apr 26 '16 at 11:53 on
source share

I installed the new version 2.10 just now, and the problem seems to be resolved. So you can try.

+1
Apr 28 '16 at 1:42 on
source share

Downgraded Android version is not a curect way to fix the problem. If you like, you will lose new testing and development functions in android studio.same, like the problem I encountered earlier, when I upgrade to android 2.1.but I have my problem through restarting Android studio, selecting msgstr "install-> invalid caches / reboot ". Although your problem still persists, try creating another avd with a suitable system image. Make sure you download the appropriate system image to run your emulator on the processor.
I solved the problem of running the emulator in android 2.1 by downloading the x86-64 system image using api level 23.try to load this system image if you are using the 64-bit version.

+1
May 18 '16 at 6:47 a.m.
source share

I had the same problem and solved it by following these steps:

  • Uninstall the application, in my case, from the actual equipment connected via USB.

  • This is a key step! Remove the application from Recently Uninstalled Applications

  • Restore the application.

  • Run it.

+1
Aug 16 '16 at 3:53 on
source share

To fix this unpleasant problem, I performed the following three steps:

  • The -r flag is enabled in the installation flags. This can be done by clicking Run → Edit Configurations. Now go to the "General" tab and enter -r in the "Set Flags" text area.

  • Click “File” and select “Invalid Cache / Restart”.

  • Uninstall previous versions of the application. Under this, I want to delete it by going to the section General → Applications and deleting the application. Dragging the application icon into the trash on the main screen will not solve the problem.

+1
May 14 '17 at 8:48
source share

There is a simple solution to this problem if you use the application on an emulator. This is due to storage space limitations. Increasing the memory capacity of the emulator should solve this problem. Android P Emulator with less space on the disk

You can either free up some storage space from the emulator itself, or increase the storage space from AVD Manager.

+1
Apr 03 '18 at 6:09
source share

Although I'm not sure about the specific reason for this problem, I just found a solution when I cleaned up the project. So go to Build -> Clean project . This should help you.

0
Jul 14 '16 at 6:49
source share

I had the same problem, because the latest version of my application was disabled in the phone or emulator to solve the problem, I just activated the application in my phone (settings-> apps-> disabled), and I recompiled and the problem was solved.

0
Nov 22 '17 at 12:28
source share

I had this problem on the LG-K220. It turned out that I had previously uninstalled this application, but this phone model had a system application that at first does not uninstall the application, but saves it as in a basket. Not surprisingly, Android Studio had problems installing a new one. I completely uninstalled the application and then it worked.

0
May 03 '18 at 15:48
source share

the solution is simple - just remove the package using the adb command after connecting to the device

 adb uninstall PACKAGE NAME 

replace "PACKAGE NAME" with the name of the application you want to remove, and press "Enter".

0
Aug 20 '19 at 18:18
source share

In my experience, this error occurs when you manually uninstall apk when building it or installing it through android studio.

In this case, I just create apk and install it on the AVD or phone. After it will work as usual.

Hope this helps someone.

0
Aug 29 '19 at 18:29
source share

Perhaps you just set up your phone or emulator to refuse all requests to install apk via USB. Open your phone’s settings and change it to allow installation. The problem is resolved. Hope this works for you!

-one
May 22 '17 at 8:01
source share

I tried almost all the solutions found in the community, but the activity to start Error never went away. Now I have found the reason for my business.

I use a phone connected to the USB port of LG K20 Plus to check my projects created on the Android 2.3.3 platform, when I start a project, the message “Startup error” will appear on the phone, it will start normally again if the remote project is reinstalled.

I hope this helps people with the same or similar mistake in your developing projects.

-one
Oct. 16 '17 at 0:00
source share



All Articles