android studio trying to start an unexistring activity - android

I installed android studio in a usb flash drive because i work on different computers and i don't always wanted to install it. Recently i started it on an
computer that just a week ago worked but when i run the project the IDE try to
run an activity that i've deleated in other computer. I have tried to
rebuild the project, delete the .idea and .gradle folder, disable instant run. Nothing of those success. What can i do?
Error message:
Error while executing: am start -n "bonfra04.com.application/bonfra04.com.application.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=bonfra04.com.application/.MainActivity }
Error type 3
Error: Activity class {bonfra04.com.application/bonfra04.com.application.MainActivity} does not exist.
Error while Launching activity
Now MainActivity does not exist any more.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bonfra04.com.application">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/GameTheme">
<activity android:name=".Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Game"></activity>
<activity android:name=".ScoreViewer"></activity>
</application>
Directory structure:

In Android Studio at the left of the green Run button, drop down the "app" list and press "Edit Configurations". In the "General" tab check the "Launch options". You must see "Default Activity". If not select it and click OK.

Check your manifest, I bet this activity is still defined as a launcher activity.

Related

I can not see hello world app in Android Studio

Hi I have installed Android studio correctly. I made AVD for e.q Marshmallow and project on the same platform. after press RUN, AVD turns on. I can do everything on emulated android phone(other issue- after running this my computer dramticly slowing down) but I should see my "Hello world" app, there is not there. I'm getting following error
Unexpected error while executing: am start -n "com.example.zad2/com.example.zad2.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
where zad2 is my project name.
On Stacfoverflow i saw tips to add into manifest some filter code but I already have it:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Zad2">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Yea don't trouble friends. I found this post: Session 'app': Error Launching activity
and I unistalled my app from AVD :)

Error type 3 ,i have already declared launcher activity and also done gradle

Error while executing: am start -n
"com.example.myapplication/com.example.myapplication.Detail" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.myapplication/.Detail }
Error type 3
Error: Activity class {com.example.myapplication/com.example.myapplication.Detail} does not exist.
Error while Launching activity
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
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>
<activity android:name=".Detail"
android:label="SQLite Example - Details"></activity>
</application>
</manifest>
It is a easy problem which is happened when you migrate to androidX (at least it happened for me by this reason).
An easy solution is:
making a new project (same package name as the current one)
go to app\src\main and delete all files in main directory (for this new project)
go to app\src\main and copy all files in main directory (for the old project)
past the files in app\src\main directory (the new project)
run the new project

Why my android studio doesn't launch app automatically after install(run)

I build and run my project by clicking the green arrow on android studio, my app should be launched automatically but it just installed then nothing happened.
I've tried reinstall android studio and create a new project but it still not fixed.
This is my Run/Debug configuration (Just the default setting).
This is the android manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
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>
I found the error message as below, why it disconnects?
04/20 16:37:14: Launching app
$ adb install-multiple -r -t [my project path]\app\build\intermediates\split-apk\debug\slices\slice_2.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_8.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_7.apk [my project path]\app\build\intermediates\resources\instant-run\debug\resources-debug.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_9.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_5.apk [my project path]\app\build\intermediates\split-apk\debug\dep\dependencies.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_6.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_0.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_1.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_4.apk [my project path]\app\build\intermediates\split-apk\debug\slices\slice_3.apk [my project path]\app\build\intermediates\instant-run-apk\debug\app-debug.apk
Device emulator-5556disconnected, monitoring stopped.
Split APKs installed in 1 s 572 ms
Lunch options > Launch > select as default Activity
Happy coding !!!
It caused by chrome extension - VideoStream, it using the same port 5556 as adb. Just terminate or uninstall it then work fine.
ref.
https://stackoverflow.com/a/54660175/4557420
https://stackoverflow.com/a/54731956/4557420

Android Studio launches wrong Activity when merging AndroidManifest from ProductFlavorBuildType hybrid directory

I'm using Android Studio 2.1.3 (Mac OS X) and com.android.tools.build:gradle:2.1.3. I've already tried invalidating cache and restarting and clean builds.
I have a project with many ProductFlavors, all of which use the same starting activity save one (this one is a paid version that uses the licensing library, all the others are free so I don't bother, although a solution might just be to use the licensed version of the activity for all flavors but skip the licensing unless a resource is set... just seems too easy to hack). I thus have 2 AndroidManifest.xml files:
// app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app">
...
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
android:name="com.company.app.TabsFragmentActivity"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
// app/src/PaidFlavor/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.app">
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
tools:node="merge"
android:name="com.company.app.TabsFragmentActivityLicensed"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
tools:node="remove"
android:name="com.company.app.TabsFragmentActivity"/>
</application>
</manifest>
This works great, and I can inspect the generated intermediate (merged) AndroidManifest.xml, and indeed the TabsFragmentActivity activity is removed, and the TabsFragmentActivityLicensed is added, and all is right with the world.
But I don't want the debug version (build type) to be licensed. Again, I can work around it easy enough in code, but it's the principle of the matter! So I thought it would be easy to just move
app/src/PaidFlavor/AndroidManifest.xml
to
app/src/PaidFlavorRelease/AndroidManifest.xml
This is where things go wrong. Everything builds without error, and I look at the intermediate (merged) manifest and it still looks correct. However, Android Studio tries to launch the PaidFlavor with release build type as:
adb shell am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Wrong activity! Where's it getting it from? Am I using the wrong subdirectory (PaidFlavorRelease/)? This results in the obvious error:
Error while executing: am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.project/com.company.app.TabsFragmentActivity }
Error type 3
Error: Activity class {com.company.project/com.company.app.TabsFragmentActivity} does not exist.
Error while Launching activity

Launcher Activity Issue Android

I created a splash screen for my android application. In my AndroidManifest I set the SplashScreen Activity as Launcher and action as MAIN. After that I changed the HomeActivity's intentfilter.
Here is my android manifest file:
<application
android:allowBackup="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreenActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ActivityHome"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.ACTIVITHOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".Receivers.NetworkReceiver"></receiver>
</application>
I have both these activities inside the default package. Now, when I try to test the application in device, I get the following error:
Error while executing: am start -n "com.sdz.myapp/com.sdz.myapp.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sdz.myapp/.SplashScreenActivity }
Error type 3
Error: Activity class {com.sdz.myapp/com.sdz.myapp.SplashScreenActivity} does not exist.
Error while Launching activity
This is how my project structure looks like:
src
-com.sdz.myapp
----ActivityHome
----SplashScreenActivity
I restarted android studio but still the error is there. I dont know what is causing this.
I ran into this as well. I actually had to uninstall the apk from the device before it would work... which was really odd as the app wasn't showing up on my list of apps on the phone.
Here's what I did:
Opened up command line
Ran 'adb devices' to make sure my device was connected
ran 'adb uninstall ' Replace with "com.whatever.blah"
You should see a message saying it uninstall successfully
Try installing from Android Studio again and it should work
I have no idea how it gets in this weird state. :-/
Please change your android:name value at your activity tag with full name and first clean project . After that try to run your application again
<activity android:name="com.sdz.myapp.SplashScreenActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have this same issue occasionally. The solution was to build the APK (menu "Build > Build APK") and install it manually in the phone. After that the error disappears.
I tried all of the above plus even delete the build folder and still did not work. The solution for me was: On your Android Studio go to File->Sync Project with Gradle Files

Categories

Resources