After the Android Studio 2.0 update while the gradle build finishes I get this :
Session 'app': Error Launching activity .
It prevents the app from starting but it's installed in my emulator.
This is what comes up in the Run tab :
Unexpected error while executing: am start -n "com.example.user.ypologismosmoriwn/com.example.user.ypologismosmoriwn.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
Here is the code:
package com.example.user.ypologismosmoriwn;
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);
}
}
It's just an empty Activity,nothing added
and the XML code is just a Relative Layout with 4 Texts and 3 Check Boxes
This is the logcat i am getting
Thanks anyone who is willing to help
I also faced this issue after I updated to AS2.0. I found that it is because of the instant run enabled. So my solution is to disable the "instant run". and it worked. To disable "instant run", you can go to Preference Dialog ( May be Setting dialog on Windows), then select Build, Execution, Deployment > Instant Run, and uncheck all the checkbox to disable Instant Run.
This is my temporary solution and it may help you. Later, I'll find a better way to this issue.
update by 2016/06/06
A better solution instead of disabling instant run.
Remove the .idea folder and .gradle folder, then click button Sync Project with Gradle Files (or through the menu File -> Sync Project with Gradle Files), after this process finished, you are able to run your app as normal.
Good Luck~
If you are using Android 7.0 and above it is likely that the app was installed in two places (Guest and Admin) and you only Uninstalled it for only one user and that is causing problems.
To solve that, go to:
Settings -> Apps & Notifications -> See all Apps -> find the app you are trying to install.
Then click the menu on the top right corner and select Uninstall for all users
Run Your App from Android Studio it should work.
Try reinstalling the app, this solved the error for me. The trick was that, I uninstalled my app, but Android didn't truly uninstall it. On my phone, there is a guest user (my sister uses it sometimes). If you uninstall the app from your main user, it will still be available on the phone, but only for the guest user. It looks like Android Studio can't handle this case. I guess it detects that the app is installed, so it will not be reinstalled again for the current user, hence the OS can't access and launch the activity. Nice bug, I'll report it.
I've had same issue, rebuilding project clears the error for me.
build -> rebuild project -> run
This is issue with 2.0+ studio
Issue 206036: No local changes, not deploying APK
I found the nice workaround here
just add -r flag here in edit configurations
and also disabling instant
Waiting to get Instant run Feature run smoothly soon with no type 3 error more!!
For me the problem was that the app I was trying to launch was already installed under a different user account on my phone. I saw this when I went to Settings->apps looking to uninstall it. I switched to the other user, uninstalled it, came back to the original user, and was able to install and launch the app from Android Studio with no more problems.
I spent a whole lot of hours on this exact issue. The "instant run" fix was a total fail. And I wasn't missing the android.intent.category.LAUNCHER I removed all applicable Android Studio and SDK code and re-installed. Still a no go.
Ultimately I think my issue was marginal hardware. I'm running on a laptop with a AMD A6-4400M processor. There is no hardware acceleration / virtualization tools available. I was just running the standard Android Studio / Google emulator. It was painfully slow, and although I was eventually able to see the emulator and interact with it, I was never able to connect the emulator to Android Studio to upload APK's.
But I did discover an awesome fix.
Remove all Android Virtual Devices and install the GenyMotion Emulator (with VirtualBox).
I've tried GenyMotion emulators before (with a Linux) and it didn't make much difference in load up speed.
On this Windows 10 machine it works exceptionally well. Its pretty quick, easily connects to Android Studio and works well deploying my apps.
GenyMotion offers one personal use device at no cost. Kudos to the GenyMotion team!
Answer provided here in case anybody else gets stuck with this error, possibly with this root cause.
I got the same problem and fixed it with this answer.
But this problem was created by myself, as I tried to debug my unit tests. Therefore I had to uncheck the Use in-process build option of the AS Settings in Build, Execution, Deployment > Compiler.
So in my case it works, if I disabled instant run. But it also works, as I enabled instant run and also the Use in-process build option.
Just run adb uninstall <package name> in your terminal
and reinstall the app again.
Hope it helps.
Same issue, but for me problem was that Android Studio couldn't find my Default Activity. When I specified the intent filter to catch the MAIN action intent, I didn't specify the LAUNCHER category, and that caused the 'Error Launching activity' issue.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <-- forgot
</intent-filter>
Just Run --> clean and rerun , In my case it helps.
Prompts automatically like following message
would you uninstall already installed activity with same name
if activity is already installed first uninstall it and make project ready after installing app.
I had this error because of my stupidity. In the manifest.xml I have wrongly declared two Activity as Launcher. Make sure you have only one activity as Launcher.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I was facing the same problem in android studio 2.1.2 but worked after selecting Build -> Clean Project or alternatively Run -> Clean and Rerun
I tried all suggested answers. I found out this is a hardware issue on Android N phone with studio 2.3 version. App launches fine on phones below version 7.
I've fixed the issue using this solution.If you are running the application in USB device then close all the virtual device like : genymotion / virtual machine .
Just disable Instant Run.
Go To File >> Settings >> Build, Execute, Deployment >> Instant Run
Uncheck The Box that says Enable instant run to hot swap code/resource changes on deploy
Re-run the emulator.
OK already so many possible solutions for this problem, if none of those works then try this.
I faced this problem when I first uninstalled my app then tried reinstalling from ADB. But then after trying these many solutions, I realized that uninstalling app nowadays does not really uninstall it. It just disables it for few days so that it can be enabled in case you change your mind.
Now I am not sure whether its done by LG or Native Android Nougat.
I just went in Settings-> apps-> my-app and uninstalled it completely. After that from Android studio I am able to install the app again properly without this error.
Adb also throws this error if applicationId, package of launching activity or module name contains error substring
None of the existing answers helped me as I had the same app installed in my other profile. Solution -
Switch to the other profile
Uninstall the app from 2nd profile
Switch back
I tried the above answer. However, none of the solutiond worked for me. I changed the emulator to USB and the code is running on the USB target device prefectly!
All answers did not work for me.This error raised when I was trying to rename the app package.I have ended up creating a new project with the new package name and move my files to the new one.
I've fixed the issue (on my Anroid watch Moto 360) by uninstalling the app before installing from AS
it occured when I changed the applicationId in app gradle file.
It works for me after I sync gradle.
Uninstall App on your real device or emulator. Then Run again.
It's worked for me.
I used Android Studio 2.3.3
I tried, clean & rebuild project and Invalidate Cache & Restart also manually removed .gradle and .idea folders, but that didn't solved the issue.
I have 3 user acounts in my phone. So, I didn't select Uninstall for all users, and it only uninstall my app from first user account, but it was still there in guest and second user account.
So, I removed it from rest of the accounts and it solved my issue!!
I had same problem. I was using AVD with arm processor image and received this same message. The only way for me to make Android Studio 2.1.2 runs the app with instant run was change to an X86 processor image. The error was gone and ( until this moment) I think the emulator works faster than ARM emulated. My workstation configuration is Intel I5, 6Gb RAM. Maybe this helps until next fix.
Disable "instant run", you can go to Preference Dialog ( May be Setting dialog on Windows), then select Build, Execution, Deployment > Instant Run, and uncheck all the checkbox to disable Instant Run.
And Reboot your Device this should make the thing work....instant run has a bug in Android studio 2+
This should do the magic
I got the same error.
This issue was caused by uninstalling the app from the device (uninstalled from only 1 user)
Solved by logging into the other user and uninstall the app from there.
and it solved.
I did all suggestions above, but they didn't work!
I rebuilt the project, uninstalled the app from my real device, unplugged USB, then I run Android Studio and run the app on my real device and the issue was gone.
Hope this helps!
I had the same error as in the headline.
after I changed the version name and version code in the gradle,
the sync happened and then it worked.
so maybe even only sync can help sometimes.
Related
I recently downloaded Android Studio 2.0 and create a new startup app and did not add anything code by myself. After running the app, android studio installs the APK on emulator successfully but does not launch the app instead it gives 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 provided solution isn't working for me either. I also did not add anything in 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>
I had exactly this same problem today [Android Studio 2.3.3, Android 8.0 on the phone]
This is what I discovered. The app that I was trying to install was not shown in the android Application window [the one where you have them all]. But once I went in: Settings->Apps&Notifications->AppInfo I could see this screenshot where it was said that this app was "not installed for this user":
At that point I entered the app->clicked on the three points in the top right corner->Uninstall for all the users
Now when I tried to run the project through Android Studio the error message disappeared and the app was correctly installed
Hope this helps, have a good day
Antonino
If you are using android 2.0+, take the following steps
1. Go to run
2. Select edit configurations..
3. type -r in the Install Flags text field
4. Apply and Ok then run program again
tested(23/07/2016)
I encounter the same problem in AVD, when first start app it was fine but when launch the app again it reports "Error while Launching activity".
My resolution is: in AVD, uninstall the apk, maybe the reason is the new Android studio has an issue when install apk to a AVD.
Thanks, Yu
There is issue with studio 2.0+ instant run feature
Work around provided at Android Open Source Project - Issue Tracker
Don't waste time in re installation of studio or cleaning gradle build file often .
Just add -r flag in
Install flags in
Run->Edit configurations->General
For me, I was unable to solve the problem, which is absolutely infuriating for a piece of software as important as this. I'm a diehard Android guy, and this is frankly unacceptable, that I cannot even debug an app.
However, I did find a workaround that might help some.
For me, the Session 'app': Error Launching activity error didn't prevent the app being installed, but it did prevent debugging the app since there was no way to attach a debugger. However, there is another way.
Start the app on the phone, then click attach debugger to Android process (near the regular debug button, looks just like it), this allows you to attach a debugger to an already running app.
It's annoying as hell, but at least I can debug my app again.
After struggling for hours I came to conclusion that the problem is with the user files stored in AVD. Whenever I choose Wipe Data of an AVD the app works like a charm and does not show the error. But its really painful for developers to Wipe Data everytime before running the app as Wipe Data will only work if your emulator is not running.
In another test phase, I wiped the data of AVD and then started the app, it ran successully; but when I tried to run the app second time it shows me that error again.
Error while Launching activity
Then I opened 'Manage Apps' and delete my app from emulator. But it did not work either.
Workaround
Delete Android Studio but don't delete the SDK
Download and Install Android Studio 1.5.1 from here http://tools.android.com/download/studio/stable
Another Workaround (But that does not work for me)
Session 'app': Error Launching activity
Final Conclusion
I think the problem is with somewhere when we tried to 'Run' the app on second time. It does not uninstall the previous version of the app so when it found the package name already there it does not install the app then; results in error launching the activity.
I've been working on this same exact problem for the last 8 hours...you've had no issues after rolling back from 2.0 to 1.5.1?
I've noticed that, even with the error, running the app works fine sometimes.
You're not alone, brother. I'll be sure to update when I figure out the solution.
Also, what are your specs? I'm running the following:
Windows 7
AMD FX(tm)-8120 8-Core
AVD:
Android 6.0
CPU/ABI: Google APIs ARM (armeabi-v7a)
Target: API lvl 23
No accelerometer
heapSize: 64
If you want more details, let me know. A sample size of 2 is always better than 1.
I have been install the new version 2.10 just now ,and the problem seems like to be solved.So you can try it.
downgrading android version is not the curect way to fix the problem..if you like that you will lose new features of testing and developing in android studio.same kinda problem i faced previously when i upgrade to android 2.1.but i resolve my problem through restarting the android studio by selecting option of
"setting->invalid caches/restart".
Even though your problem is not fixed then try to create another avd with suitable system image.
make sure that you have downloaded a suitable system image for your emulator to run in cpu.
i solved my emulator launching problem in android 2.1 by downloading system image x86-64 with api level 23.try to download this system image if you are using 64 bit.
I had the same problem and solved it by following these steps:
Uninstall the app, in my case, from the actual hardware that is connected over the USB.
This is the key step! Uninstall the app from the "Recently uninstalled apps"
Rebuild the app.
Run it.
To fix this annoying problem I followed the three following steps:
Included the -r flag in the Install Flags. This may be
accomplished by clicking on Run -> Edit Configurations. Now
Select the General tab and type -r in the Install Flags text
area.
Click on File and select Invalidate Caches / Restart.
Uninstall earlier versions of the app. By this I mean to remove it by accessing General -> Apps and uninstall the app. Dragging and dropping the icon of the app to the trash in the home screen will not fix the issue.
There's a simple solution to this problem if you're running the app on an Emulator. This happens because of Storage space constraints. Increasing the storage space of the Emulator should solve this issue.
You can either free up some storage space from the Emulator itself or increase the storage space from the AVD Manager.
This happened to me after changing manifest permissions and trying to restart the app using AndroidStudio 3.5.1. The fix was to uninstall the app using adb and restart.
adb uninstall <your app package name>
Though I'm not sure about the exact reason for this problem, I just found a solution when I cleaned the project.
So, go to Build -> Clean project. This should help you
I had the same problem, in fact the last version of my application was disabled in the phone or emulator, to solve the problem just reactivated the application in my phone (settings-> apps-> disabled) and I recompile and the problem was solved.
I had this problem on LG-K220. It turned out that I have previously deinstalled this app, but this phone model had a system app which does not deinstall the app at first, but keeps it like in a recycle bin. No wonder Android Studio had troubles installing a new one. I completely removed the app and then it worked.
the solution is simple just uninstall package using adb command after you connect to your device
adb uninstall PACKAGE NAME
replace “PACKAGE NAME” with the name of the application you want to delete and press “Enter.”
In my experience this error occurs when you manually uninstall your apk when it's building or installing via android studio.
In a such case I simply create a apk and install it on the AVD or phone. After It will work as usual.
Hope this will help to someone.
Maybe you just set your phone or emulator to refuse all the requests of installing apk through USB.
Open your phone setting and change this to allow the installing. The problem is solved.
Hope it works for you!
I tried almost every solution found in the community, but the Error Launching activity never gone. Now I found what's the reason of my case.
I use a USB connected LG K20 Plus phone to test my projects built on the Android Studio 2.3.3, the Error Launching activity will appear if I uninstall the project in the phone, it will launch normally again if the deleted project is reinstalled.
I hope this will help people having the same or similar Error in your developing projects.
I am trying to run my app on my Xiaomi RedMi S2 from Android Studio 3.5. It throws an error while installing the app on the phone:
Installation did not succeed.
The application could not be installed.
Installation failed due to: 'null'
I had the Same issue on a MAC, this is how I solve it,
note: I was tried the method that mention #Manoj Kumar,
Un check this field in Preferences/Build,Execution,Deployment/Debugger
1.Open run/debug configuration dialog:-
Run> edit configurations.
Navigate to You app > General > Installation Options > Install Flags.
add install flags -r -t.
Note: This flags means adb install -r -t apk path
I hope this will help.
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present.
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
For me, restarting the Android Studio solved the issue.
File> Invalidate Cache / Restart
Restarting the device after enabling developer mode and allowing usb debugging did the trick for me.
You has installed the app which has same package name with different debug signature file.
The different signature file lead to the fault
At first please uninstall the apk that you has installed with different signature file。
Then you install the apk again ,You'll sucess!
When you connect the mobile, it starts in the charging mode.
Simply change the mode to Transfer Mode (Transfer Media or photos mode).
Now install the app again and it will work.
It may be because of your phone's memory is full. you can delete some data from your phone and then try. for me it worked.
Tip: run from terminal adb install path/to/app.apk
Why? Cause it will give more information about the error - actually pointing to the place in manifest with the error. For example - in my case it was: 'Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]'
A simple (unintended) restart to the computer did it for me (I tried to run on emulator)
In my case I was using third party library, I have removed that library from gradle and reinstall the app. Successful
Add this line to your '/gradle.properties':
# gradle.properties
android.injected.testOnly=false
Check https://gist.github.com/xujiaao/5fd127a72979cdc3c70dcc1324786f87 ,it work for me.
Just use in this link. Disable Preference -> Build,Execution,Deployment -> Debugger -> Use libusb backend
Uncheck Use libusb backend
that's all. Enjoy your coding...
Chech to manifest file and search for a required library tag. And delete it. I solve it by this way.
I was trying everything but nothing seemed to work. But then I suddenly noticed that my phone blocked installation, so I unchecked "reject this to install" and at the another try the security checkbox popup, asking for letting the installation. After allowing everything worked.
Conclusion: I just were probably too angry that i didn't noticed this popup earlier.
Just check in the AndroidManifest.xml file to make sure you are using permission and libraries that you need for your app. In some cases you may have wearable libraries and permissions in your AndroidManifest.xml file and yet you do not need them. This happened to me when I was adding more activities and Android Studio was creating them as Wearable Activities
I'm trying every thing from the answers but only one solution is just free some space on your phone for proper install the debagged app.
I had this problem at one point in time. the only solution that worked for me was to delete the SDK and download a new vision. It turned out that ADB had a problem and it was not able to detect my device. uninstalling the SDK and installing another resolved the problem for me
Create a signed apk and drag that apk to the emulated device, that worked for me
go to the path of your debug apk, and rename of your apk like :
myApp.apk to myApp1.apk(just rename it)
and try to run it again.
its works for me every time :)
TRY THIS!
Delete the build folder in your App and re-build the project, it should work now.
Accept agreement of terms and conditions by opening Google Maps and Google Chrome on a newly created emulator, your application might be using Google play or location services.
I was faced this same error while running application. I am just rebuild the program and run again the application..
For me ı had this problem i fixed it
because i did not use Android studio Emulator i was using another one
i fixed the problem when I enabled Developer Mode from Emulator
and that is all for
I hope that can help some one like me
Regards
As I am currently using IntelliJ IDEA 2021,
In order to work for me, I had to disconnect android device(Emulator)
to Computer by USB and Free up some space on phone storage
Lastly It was to refresh my device by restarting it(phone)
Again, I had to go to:
Settings, Debugger,
And Check Hide debug Window on process termination
I hope this helps, if U are using IntelliJ IDEA, for instance.
You might wana check your phone storage too. Your apk wouldn't install if there is no space
I resolved the problem by switching off the emulator, clean the project and rebuild it again.
Its because the devie on which you want to install the app does not have enough space, just clear some items to get space. Then try agian
Yesterday my app was running perfect from Android Studio but today when I started working on my app and running it i am getting error message continuously
Installation failed with message Failed to establish session.
Screen :
On click OK getting error message
Session 'app':Error Installing APKs
And App is not exist(already Uninstalled) in device. Please suggest me what to do ?
Again in this issue also I found Instant Run buggy. When I disable the Instant run and run the app again App starts successfully installing in the Device without showing any error Window.
I hope google will sort out these Issues with Instant run soon.
Steps to disable Instant Run from Android Studio:
File > Settings > Build,Execution,Deployment > Instant Run > Un-check
(Enable Instant Run to hot swap code)
If you use MIUI ROM
Go to the developer option and in that disable MIUI optimization.You will be asked to reboot your phone.
Reboot it and then run the app.
Your APK file is missing . So , Clean Project >> Build APK >> Run the project .
For those who uses Xiaomi phones, follow these steps:
Settings-> Additional Settings-> Developer options
Turn off MIUI Optimization and reboot your phone
Last Disable verify app over USB
Your device will respond properly.
Also enable install via USB
I had the same issue in Android studio 2.3 when I tried to test the app using Xiaomi's Mi5 and Mi4 phones. Disabling instant run didn't help me. So here is what I did.
Turn Off MIUI optimization in the Developer Options in the phone.
Then the device will be rebooted and then you'll be able to test the app over the phone.
Using this method you can still use instant run option in android studio. So this will fix your problem at least temporary. Hope that we'll be able to use MIUI optimization in the near future updates :)
In my case, it was because my emulator ran out of disk space.
In my case, it was very a silly and funny mistake. I, accidentally without actually knowing, checked "Android Debug Bridge, Use libUsb backend". Actually it should stay unchecked..
In Mac Pro, Go Preferences - > Build, Execution,Deployment -> Debugger.
**** For MAC OSX/Windows ****
Goto *
Android Studio - Preferences (In OSX)
Android Studio - File -> Settings (In Windows)
in the menu bar then select
Build,Execution,Deployment - Instant run
then uncheck it and rebuild it will works
Finally I've SOLVED it!
Below a temporary solution. Issue was reported to Google.
First of all I found in Run log that Android Studion 2.3 tries to install app-debug.apk from many slices, like this:
$ adb install-multiple -r
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_1.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\dep\dependencies.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_0.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_2.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_9.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_4.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_3.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_5.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_8.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_7.apk
E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_6.apk
E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk
Then I tried to install only app-debug.apk from command line by:
adb install -d E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk
App was installed successfully but was failed to run on my phone.
And finally:
I recompiled app-debug.apk from command line as:
gradlew.bat assembleDebug
Repeat installation of app-debug.apk from command line and became happy:
adb install -rd E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk
This is definitely some gradle problem in AndroidStudio 2.3.
Go to Build --> Clean Project --> Run
Thats all it takes.
I had the same issue in MIUI. Enabling OEM unlocking worked for me without disabling MIUI optimization.
Below is a screenshot of my Redmi 3s prime developer options setting:
In my own case, it was because my phone was out of space. For people that are facing this problem right now, if Clean Project + Build APKs does not work, check the available space on your phone or emulator.
I hope this helps.. Merry coding!
I found the solution go to
settings>build,execute,deployment>instant run>Enable instant run to hot swap code /resource change on deploy(unchecked this option)
This will work on 3.4 android studio too. thanks
Try disabling the Instant run in Settings.
Easily can be solved this problem.
Ex:- in Huawei GR3 mobile,
Goto Setting in your mobile -> Storage -> Storage Cleaner
Change your applicationId in the android/app/build.gradle file.
For example:
// Change this
applicationId "com.example.myAndroidApp"
//
// to this
applicationId "com.example.somethingElse"
Then Sync your gradle then you can able to install your app,
if the previous applicationId is your production id the again change it the previous one now the device will allow to install the app.
Hope this may help you....
This is caused by "instant run" feature, you can disable it by:
Open the Settings or Preferences dialog. Navigate to Build, Execution, Deployment > Instant Run.
Uncheck the box next to Enable Instant Run and u are ready to go.
At me such error arose after renaming of a folder with the project.
Disabling Instance Run helped, but what if you do not need to disable it?
I deleted all the tags mentioning the old folder name from the file myproject\app\build\intermediates\restart-dex\debug\build-info.xml
The error has disappeared.
Just do the following step...
Build>Clean Project
after that Run project again, this worked for me
I also had the problem after globally changing the project name, applicationid and the folders containing the java files.
Disabling Instant run helped, but was not a good option, so this helped:
close Android Studio
deleted those files and folders: rm -Rf .gradle .tags local.properties .idea/workspace.xml .idea/caches/* .idea/libraries app/build
start Android Studio and let it resync everything
press run
Faced same issues on MIUI phone resolved by making MIUI account and enable install by USB.
just close your emulator and run again the problem will be solved happy coding
Sometime app doesn't show on home screen,So
Check your apps by going to setting - > apps -> and then uninstall from app setting might this work.
Here's my solution (there's no need to deactivate instant run) Do all these steps in the stated order:
1- Gradle Build (root level)
gradle
2 - Gradle build + clean (app level)
gradle app
3 - Choose app on the top bar (left of Run 'app')
4 - Clean Project:
Navigate to Build > Clean Project
And it should work now! You shouldn't disable instant run if you follow these steps
In my case Instant Run hided the real cause of the problem which was INSUFFICIENT_SPACE due to small data partition and I also got "failed to establish session" error. After disabling Instant Run, the real problem was revealed and after fixing it and enabling Instant Run it worked.
Allow or enable "Installation from USB" in the developer options.
One problem in MAC(or may be other operating systems) can also be solved with this
You need disable "Use libusb backend" in preferences--> debugger
Please tell others if this was useful for you.
Thanks to the following user and their answer: https://stackoverflow.com/a/58095554/3726185
Go to USB Debugging and disable MIUI Inspection and allow the phone to reboot. Things should be fine from here
For me I had to close the emulator and then select cold boot when re-opening it.
Before trying anything else in this post, I would do Build >> Clean Project. It solved my problem and it is the simplest solution. Sometimes, the cleaning doesnt get some links, so I also recommend you to restart your devices, either virtual or physical.
If it doesnt work out, try turning of Instant Run by File > Settings > Build,Execution,Deployment > Instant Run > Un-check
Only after trying this two simple solutions, I would try the others.
I recently downloaded Android Studio 2.0 and create a new startup app and did not add anything code by myself. After running the app, android studio installs the APK on emulator successfully but does not launch the app instead it gives 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 provided solution isn't working for me either. I also did not add anything in 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>
I had exactly this same problem today [Android Studio 2.3.3, Android 8.0 on the phone]
This is what I discovered. The app that I was trying to install was not shown in the android Application window [the one where you have them all]. But once I went in: Settings->Apps&Notifications->AppInfo I could see this screenshot where it was said that this app was "not installed for this user":
At that point I entered the app->clicked on the three points in the top right corner->Uninstall for all the users
Now when I tried to run the project through Android Studio the error message disappeared and the app was correctly installed
Hope this helps, have a good day
Antonino
If you are using android 2.0+, take the following steps
1. Go to run
2. Select edit configurations..
3. type -r in the Install Flags text field
4. Apply and Ok then run program again
tested(23/07/2016)
I encounter the same problem in AVD, when first start app it was fine but when launch the app again it reports "Error while Launching activity".
My resolution is: in AVD, uninstall the apk, maybe the reason is the new Android studio has an issue when install apk to a AVD.
Thanks, Yu
There is issue with studio 2.0+ instant run feature
Work around provided at Android Open Source Project - Issue Tracker
Don't waste time in re installation of studio or cleaning gradle build file often .
Just add -r flag in
Install flags in
Run->Edit configurations->General
For me, I was unable to solve the problem, which is absolutely infuriating for a piece of software as important as this. I'm a diehard Android guy, and this is frankly unacceptable, that I cannot even debug an app.
However, I did find a workaround that might help some.
For me, the Session 'app': Error Launching activity error didn't prevent the app being installed, but it did prevent debugging the app since there was no way to attach a debugger. However, there is another way.
Start the app on the phone, then click attach debugger to Android process (near the regular debug button, looks just like it), this allows you to attach a debugger to an already running app.
It's annoying as hell, but at least I can debug my app again.
After struggling for hours I came to conclusion that the problem is with the user files stored in AVD. Whenever I choose Wipe Data of an AVD the app works like a charm and does not show the error. But its really painful for developers to Wipe Data everytime before running the app as Wipe Data will only work if your emulator is not running.
In another test phase, I wiped the data of AVD and then started the app, it ran successully; but when I tried to run the app second time it shows me that error again.
Error while Launching activity
Then I opened 'Manage Apps' and delete my app from emulator. But it did not work either.
Workaround
Delete Android Studio but don't delete the SDK
Download and Install Android Studio 1.5.1 from here http://tools.android.com/download/studio/stable
Another Workaround (But that does not work for me)
Session 'app': Error Launching activity
Final Conclusion
I think the problem is with somewhere when we tried to 'Run' the app on second time. It does not uninstall the previous version of the app so when it found the package name already there it does not install the app then; results in error launching the activity.
I've been working on this same exact problem for the last 8 hours...you've had no issues after rolling back from 2.0 to 1.5.1?
I've noticed that, even with the error, running the app works fine sometimes.
You're not alone, brother. I'll be sure to update when I figure out the solution.
Also, what are your specs? I'm running the following:
Windows 7
AMD FX(tm)-8120 8-Core
AVD:
Android 6.0
CPU/ABI: Google APIs ARM (armeabi-v7a)
Target: API lvl 23
No accelerometer
heapSize: 64
If you want more details, let me know. A sample size of 2 is always better than 1.
I have been install the new version 2.10 just now ,and the problem seems like to be solved.So you can try it.
downgrading android version is not the curect way to fix the problem..if you like that you will lose new features of testing and developing in android studio.same kinda problem i faced previously when i upgrade to android 2.1.but i resolve my problem through restarting the android studio by selecting option of
"setting->invalid caches/restart".
Even though your problem is not fixed then try to create another avd with suitable system image.
make sure that you have downloaded a suitable system image for your emulator to run in cpu.
i solved my emulator launching problem in android 2.1 by downloading system image x86-64 with api level 23.try to download this system image if you are using 64 bit.
I had the same problem and solved it by following these steps:
Uninstall the app, in my case, from the actual hardware that is connected over the USB.
This is the key step! Uninstall the app from the "Recently uninstalled apps"
Rebuild the app.
Run it.
To fix this annoying problem I followed the three following steps:
Included the -r flag in the Install Flags. This may be
accomplished by clicking on Run -> Edit Configurations. Now
Select the General tab and type -r in the Install Flags text
area.
Click on File and select Invalidate Caches / Restart.
Uninstall earlier versions of the app. By this I mean to remove it by accessing General -> Apps and uninstall the app. Dragging and dropping the icon of the app to the trash in the home screen will not fix the issue.
There's a simple solution to this problem if you're running the app on an Emulator. This happens because of Storage space constraints. Increasing the storage space of the Emulator should solve this issue.
You can either free up some storage space from the Emulator itself or increase the storage space from the AVD Manager.
This happened to me after changing manifest permissions and trying to restart the app using AndroidStudio 3.5.1. The fix was to uninstall the app using adb and restart.
adb uninstall <your app package name>
Though I'm not sure about the exact reason for this problem, I just found a solution when I cleaned the project.
So, go to Build -> Clean project. This should help you
I had the same problem, in fact the last version of my application was disabled in the phone or emulator, to solve the problem just reactivated the application in my phone (settings-> apps-> disabled) and I recompile and the problem was solved.
I had this problem on LG-K220. It turned out that I have previously deinstalled this app, but this phone model had a system app which does not deinstall the app at first, but keeps it like in a recycle bin. No wonder Android Studio had troubles installing a new one. I completely removed the app and then it worked.
the solution is simple just uninstall package using adb command after you connect to your device
adb uninstall PACKAGE NAME
replace “PACKAGE NAME” with the name of the application you want to delete and press “Enter.”
In my experience this error occurs when you manually uninstall your apk when it's building or installing via android studio.
In a such case I simply create a apk and install it on the AVD or phone. After It will work as usual.
Hope this will help to someone.
Maybe you just set your phone or emulator to refuse all the requests of installing apk through USB.
Open your phone setting and change this to allow the installing. The problem is solved.
Hope it works for you!
I tried almost every solution found in the community, but the Error Launching activity never gone. Now I found what's the reason of my case.
I use a USB connected LG K20 Plus phone to test my projects built on the Android Studio 2.3.3, the Error Launching activity will appear if I uninstall the project in the phone, it will launch normally again if the deleted project is reinstalled.
I hope this will help people having the same or similar Error in your developing projects.
UPDATE
The supposed duplicate is a question on being stucking in "Waiting For Debugger" when executing Run, while this question is on being stucking in "Waiting For Debugger" when executing Debug, the steps to produce the problem is different, and the solution(s) are different as well.
Whenever I try to use Android Studio's Debug function, the Run status would always stuck at:
Launching application: com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity.
DEVICE SHELL COMMAND: am start -n "com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity }
While the device (Samsung Galaxy S3 Android 4.3) I'm debugging would display
This has being the case from Android Studio 0.8.8 all the way to 1.0. And on the same computer I can perform debugging using Eclipse on the same device without any issues.
So the question is what can I do to make Android Studio debugging work?
Update: The same thing happens when debugging on Nexus 7 (2013) running Android 5.0; and testing on another machine rendered the same result. I can't be the only one encountering this issue :-/
Update: Opened a bounty since this issue is so annoying. Even re-installing the app doesn't solve. Nexus 5 running Cyano, Win7 64. The ADB log is telling:
8568-8568/it.myapp:myprocess W/ActivityThread﹕ Application it.myapp is waiting for the debugger on port 8100...
8568-8568/it.myapp:myprocess I/System.out﹕ Sending WAIT chunk
Also, I can't find an easy way to disconnect nor reset ADB connection in Android Studio.
Obviously is yet another Android Studio, or rather ADB bug.
Just use this command to disable it.
adb shell am clear-debug-app
OR
Ensure there is nothing to wait for, by automatic uninstall from Device before each test-run, using Gradle's uninstallAll task, as mentioned in:
stackoverflow.com/Auto uninstall before install?
On some machines/projects the debugger do not attach automatically so you need to attach it manually (studio menu -> Run -> Attach debugger to Android process)
Restarting Testing device fix the issue for me.
Restarting Android Studio fix the issue for me.
After clicking on the run icon. If it is stuck waiting for a debugger means it is not attached to the app. You have to manually attach by clicking on Attach Debugger to Android process.
It is on the right side of the run icon. I had focus this icon in linked image.
Updated Image for Attach Debugger to Android process Icon
Debugger stopped connecting for me today and nothing worked until I tried the following:
Go to Run, Edit-Configurations, Miscellaneous Tab, uncheck 'skip installation if APK has not changed' Apply, OK.
Debugger started to connect again.
A similar question has been asked recently and the solution may work for some and is very quick.
Clearing the Intellij IDEA (Android Studio) .idea directory which
contains configuration information worked for me:
Exit Android Studio
Navigate to the project you are trying to debug
Backup any files inside .idea that you modified (if your project checks any of these into VCS)
Delete .idea directory
Open the project in Android Studio
This problem occurs when you open more than one instance of Android studio, so you need to attach the debugger manually like mentioned above.
You may need to close other instances of Android studio.
I faced this problem in android studio 3.0. Just restarted device solved.
Both of my dev machines have JDK 8 installed, the debugging function is restored once JDK 7.0.71 was installed and JAVA_HOME environmental variable was set to point to the new JDK.
Guess there's some compatibility issue between Android Studio + ADB + JDK8 (Eclipse + ADB + JDK8 works fine).
I tried the top three rated answers but failed. After rebooting my mobile, the problem is solved. No more long "Waiting for Debugger".
I just managed this problem, after several days of trying the above solutions.
So I closed the emulator, run AVD manager and in device menu choose - "wipe data"
So in next run I was free from stucked debugger.
When the Device displays the message go to Run->Attach debbuger, then select a debbuger. it'll start the activity.
This fixed it for me. Android Studio -> File -> Invalidate Caches & Restart...
I had the same problem. Restart my android phone device worked for me.
This solution works for me:
turning off the USB debugging from my device settings , and then turning it on again.
its Much quicker and easier than restart the device.
How it worked for me.
1 Start Android Device Monitor from Tools -> Android -> Android Device Monitor
2 Click on Stop for the process you are facing the issue from list of devices.
For me, the issue was: The Regional Format of Windows was ARABIC.
I simply changed the regional format to English (United States) and the error has fixed.
Steps to fix:
Go to Start -> type Region -> click on Region to open Region window -> from the Format dropdown, select English (United Stated) -> Click OK.
Restart Android Studio.
As for my case, running Android Studio Canary (preview release) along with the stable version was the problem. Running multiple instances of the same Android Studio flavor was OK, but mixing them often resulted in "Waiting For Debugger".
Most of the times this is caused because of the overload of resources and threads over the emulator. Or even for the lock of objects that GC couldn't set free: http://developer.android.com/intl/pt-br/tools/debugging/index.html
Usually, a single restart of it will solve the issue, but sometimes it asks for the IDE restart, so be sure to make both tests.
Another good test is trying to start the app in "Start mode" and then try the debug mode again...
P.S: Don't forget to kill each debug process in the IDE after each test. This will prevent your env to be more overloaded.
Android studio 3.0 and Above
Disable the instant Run
This also happens to me from time to time. Problem is that your app / device is configured to wait for debugger. In this case it is waiting for debugger before continuing execution of.
Option 1:
Attach debugger or run in debug mode. You can do this in Android Studio. Buttons to attach debugger and run in debug mode are located next to normal run mode (Bug and Bug with arrow).
Option 2:
Disable Wait for debugger. You can do this is developer settings. This option needs to be disabled in:
Root of Developer Options
Developer options -> Select debug app ->
-> Wait for debugger
This was tested on Android emulator in android studio. Other phones might have this setting different. If you can not find app's settings in debug, reinstalling app might work too.
I had the same problem. Restart my android device and closed the adb.exe process. With that I could solve the problem
Well, I guess there is a plethora of circumstances that can trigger this issue. I'm using IntelliJ Idea instead, but it's mostly the same than Android Studio. My solution for this problem:
Fastest way:
Right click on the class file that contains the main activity of your
project, and then on "Debug 'WhateverActivity'". This will create a
new run configuration that should debug fine.
Other solution, without creating a new run configuration:
Open Run/Debug configurations and within "Android app" pick the configuration you're using to debug your app.
Locate "Launch Options/Launch" there and set it to "Specified Activity" instead of "Default Activity".
In the "Launch" field just below the aforementioned option, click on the three ellipsis (three dots) button and select your main
activity.
At least it worked for me. I hope it works for others too.
Got it fixed according this solution: https://youtrack.jetbrains.com/issue/IDEA-166153
I opened <project dir>/.idea/workspace.xml replaced all the
<option name="DEBUGGER_TYPE" value="Auto" /> occurrences to
<option name="DEBUGGER_TYPE" value="Java" />
and restarted Android Studio
Open Command prompt and go to android sdk>platform-tools> adb kill-server
press enter
and again adb start-server
press enter
Non of this solutions worked for me.
In my case was that I was debugging an App from Intellij IDEA and at the same time with Android Studio. By just closing the Intellij IDEA and removing the app I was debugging just fixed my problem.
Make sure that your Active Build Variant is debug.
If you also want to make your release variant APK debuggable then make a simple change in app level build.gradle -
buildTypes {
release {
debuggable true
/*Your rest code*/
}
}
For me the problem was having IntelliJ open at the same time as Android Studio. I was using IntelliJ for back-end development at the same time as Android Studio for app development. Even though I was not doing any mobile device work with IntelliJ, it broke debugging in Android Studio.
Solution: Shutdown IntelliJ when debugging with Android Studio.
Restarting everything didn't work for me. What DID work was waiting for a few minutes while Android Studio unclogged itself. This was the first time I ran the debugger; after that, Android Studio fired up the debugger quickly.