Error while Launching activity - android

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.

Related

Error while launching app on Emulator - Android [duplicate]

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.

Android Studio Error "Installation did not succeed. The application could not be installed. Installation failed due to: 'null'"

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

Session 'app': Error Launching activity

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.

Unable to test app after upgrading to Lollipop

I am using Android Studio to develop my apps.
Since I upgraded my HTC One M8 to Lollipop, I can not use it to test my apps by "Run app" in Android Studio.
I get this error and nothing happens on my phone:
Launching application: com.project.GalleryActivity.
DEVICE SHELL COMMAND: am start -n "com.project.GalleryActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String android.os.SystemProperties.native_get(java.lang.String) (tried Java_android_os_SystemProperties_native_1get and Java_android_os_SystemProperties_native_1get__Ljava_lang_String_2)
at android.os.SystemProperties.native_get(Native Method)
at android.os.SystemProperties.get(SystemProperties.java)
at com.htc.customization.HtcCustomizationManager.<init>(HtcCustomizationManager.java)
at com.htc.customization.HtcCustomizationManager.<clinit>(HtcCustomizationManager.java)
at android.os.Environment$UserEnvironment.getCustomizationReader(Environment.java)
at android.os.Environment$UserEnvironment.isDynamicSwitchSupported(Environment.java)
at android.os.Environment$UserEnvironment.<init>(Environment.java)
at android.os.Environment.initForCurrentUser(Environment.java)
at android.os.Environment.<clinit>(Environment.java)
at android.os.Environment.getLegacyExternalStorageDirectory(Environment.java)
at android.os.Debug.<clinit>(Debug.java)
at android.ddm.DdmHandleHello.handleHELO(DdmHandleHello.java)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleHello.handleFEAT(DdmHandleHello.java)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleProfiling.handleMPRQ(DdmHandleProfiling.java)
at android.ddm.DdmHandleProfiling.handleChunk(DdmHandleProfiling.java)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java)
Aborted
My project's settings are these:
This technique used to work perfectly before upgrading and I have not change anything since that time.
I was facing the same error on Asus Zenfone 5 (ASUS_T00J) with Android 5.0. For me the solution was to switch off the "Verify Apps over USB" in the "Developer Options".
Launcher may not be the issue since I tried with Google Now Launcher as well without success. It was working fine on my Nexus 5 with Android 5.1
Workaround: disable ADB integration in Android Studio.
Tools > Android > uncheck Enable ADB integration
I'm not sure what the underlying cause is, but I found I could successfully avoid this issue by closing down all running apps on the phone before trying to Run my code on my M8.
Do you use any third-party launcher on device? I have same issue when use Aviate launcher. I switch back to BlinkFeed in Personalize->Main Screen settings and my deploy to device is stable now.
Classpath com.htc.customization.HtcCustomizationManager make me thing than this issue related to launcher.
I met the same problem on ASUS ME176C(Lollipop 5.0),
but I resolved it by setting "Select debug app" to "No". Then push apk as usual. After that, you can reselect "debug app" to target app.
I discovered a "workaround" to solve this problem
Find the HTC Blink Home Launcher and uninstall the update
(CAUTION:uninstall the launcher update will remove all icons and widgets placed on the launcher)
This works for me and it can be used debugging now without removing the apps in multitask.
This should be a bug caused by HTC?
(I am using HTC Butterfly 2 & Android 5.0.2)
I don't have the rep for commenting but i was in the same situation of #user47625 but my "Verify Apps over USB" was already off. I've tried to enlarge a bit this answer with some reasoning.
At first I've tried to change the launcher and I got some luck but was hit and miss, not a proper solution. Rebooting the phone granted a couple of hours of calm work.
Then i've found someone on google that stated:
If it is that bug: The DDMS client connects with a "Hello" when the PM process first starts and registers itself, but before it has fully initialized all the native code. It is a race in stock Android and occurs there too
So if this race occurs it doesn't occurs everytime, but every now and then, I suspect something regarding interaction of item on Android. I don't know if it's CPU, RAM or App related, but on my Zenfone 2 closing all background apps (1) and releasing the memory (2) does the trick, letting me able to debug the app properly.
I used Clean Master cause is stock with Zenfone 2, but i suspect every memory manager can do that. Give it a try
On my HTC M8, I resolved the issue by disabling "Settings -> Developer options -> Use NuPlayer(experimental)"
What I have noticed is, when I try to run the application I created long back (few years ago), I have to disable the NuPlayer. However, with new applications, I must keep the option checked.
Hope this helps....
On an Asus ZenPad, 5.0.2 I was able to solve the issue by going into Asus' Auto-start Manager (Settings -> Power management -> Auto-start Manager) and allowing my app to auto-start.
I've had a reasonable amount of success with the workaround below.
After each debugging session with your app, go to the Android Studio terminal:
> adb shell am force-stop com.your.app.package
I still occasionally get the java.lang.UnsatisfiedLinkError but only following the above command rather than in between the build/push apk/install process and attempting a debugging session.
To me, this saves a lot of wasted time building only to get the error. If the command above doesn't work, just up-arrow and re-run the command until it works without an error.
This solution worked for me, you may give it a try.
Add adb path to System Environment Variables (I'm using windows 8)
Ex: my path is "C:\Users\xxx\AppData\Local\Android\sdk\platform-tools"
Dont forget to reboot your system to take the effect!
About how to set the path and environment variables in Windows >> here

Android Emulator doesnt load the App(Crash Report)

I am having a problem in running my app in Emulator. There are no errors or warnings in the code, its running perfect in device, but when it comes to emulator, it always crashes and the error message would be like this
[2012-01-16 16:13:55 - MyApp] Failed to install MyApp.apk on device 'emulator-5554!
[2012-01-16 16:13:55 - MyApp] (null)
[2012-01-16 16:13:55 - MyApp] Launch canceled!
I have tried the following things:
Run configurations > Target > Wipe user data > Run
Uninstalling the app and run it again
Restarting the emulator
adb kill-server && adb start-server
Creating a new Emulator and running the app in it
Restarting ADB
Restarting Eclipse
Starting the Eclipse after the emulator is launched completely
Increasing the ADB connection time-out to 1000
Restarting the System
Deleted the emulators and created new emulators and run in it after they are completely loaded
I don't know what else should I do. Sometimes if I run in a new Emulator the app runs for the first time and if I run it again after sometime, its the same crash report. I am not able to understand what is the problem.
Can anyone please suggest me what should I do now and where is the problem?
The Emulator used to work well before. This problem started a few days back.
Any help will be appreciated. Thanks All.
Have you defined all of your Activities correctly and completely in AndroidManifest.xml?
Can you paste the definition of your AndroidManifest.xml here?
Try that.
More possibilities:
Real refresh of AVD. It is funny, but Eclipse remembers your emulator. And if you turn it off and on it will be the same old good (or bad) one. You could reinstall all Eclipse for a real refresh. Or use a shorter, but tricky way. Change the max VM app heap size of the emulator. (Android SDK and AVD manager - Virtual device - Edit) Create it. Now you have a brand new emulator. Funny, isn't it? Now you can change the heap size back, if you wish.
Really, I think, you can maybe change any emulator parameter for the effect. Only I stumbled upon it by heap size and stuck to do it this way.
Try to repair the path.
Set the path environment variable with the path of "platform-tools" and "tools" found in the "sdk-home".
On windows(vista):- 1.Go to "Control Panel\System". 2.Select "Advanced System Settings". 3.Select the "Environment variable". 4.Set the path environment variable under the system variable with values "SDKHOME\platform-tools;SDKHOME\tools". Where "SDKHOME" is the home folder of Android sdk.
Check,if APK version of the application sits with that of the
emulator.
Try to set a longer waiting time for launch.
Increase AVD heap and SD card
Maybe, it would be good to try to recall all the changes that were done before the problem appeared?
Oh! One more: Don't you have by accident simultaneously launched emulator and connected device? If you have the same application (ssame name) on both, they could conflict in a similar way! They simply won't let each other to be launched
If nothing helps:
I was already so tired of Eclipse errors, that I have installed the IntelliJ Idea IDE, too. Now, if for the same project applications behave idself differently on both IDES, the problem is in IDE setting or emulator. If the problem is the same on both, I look for a bug in my application or the external device. Once I had a problem in OS - had to restart Linux. But in your case it is the most probable, that the problem is in AVD. I am afraid, the only variant you haven't try yet is to reinstall Eclipse. Uninstall, remove everything from the application except code, layouts and Manifest, and install Eclipse anew. Or make other Eclipse installation, with its own workshop. You can try the last version. But if the problem is in some setting, you can set it again...
Sorry, I have put here all methods I used or found.
here you can find a similar problem and the proposed accepted solution:
Honeycomb preview - can not install my app on emulator under Eclipse
I hope this helps.
This could be due to Antivirus/Firewall software installed on your PC. Have you tried to disable it?
You should also ensure that versions of Eclipse, ADT and Android SDK are up-to-date and compatible. Have you tried to contact update sites in Eclipse and in Android SDK manager? By the way, what versions of the that software do you use?
Let's go step by step.....
1º- You should try to start the emulator without the application installed.
2º- Once it is running correctly, try to install another .apk(like for example one default one....)
3º- Now, try to run the .apk. If the problem continues, try to delete the current VM and install another new one.
Can you see Emulator in "adb devices"? If yes, can you install any .apk?
If not - you have propablly something wrong with sdk
As some people have answered already partly. Make sure of a couple things which are very important specially because of the latest Android tools releases which requires.
The latest eclipse version. Yes, very very important:
http://www.eclipse.org/downloads/packages/eclipse-classic-371/indigosr1
Make sure you update the Android ADT plugin for eclipse:
http://developer.android.com/sdk/eclipse-adt.html#installing
I've encountered similar issue and that was what has helped. Restart your computer too possible?...
Use command prompt to start emulator
emulator.exe -avd google2.2 -scale 0.7 -dns-server 8.8.8.8
it may help you.
try cleaning your project or deleting the .APK file in the bin directory of your project.

Categories

Resources