How do I fix this error in Android Studio? - android

I've been getting this error every now and then, and once I thought it was fixed, it just came back:
Error while executing: am start -n "com.example.wolfixfinal/com.example.wolfixfinal.MainActivity" -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.wolfixfinal/.MainActivity }
Error type 3
Error: Activity class {com.example.wolfixfinal/com.example.wolfixfinal.MainActivity} does not exist.
Error while Launching activity
Failed to launch an application on all devices
I've made two or three other questions about this topic and it's getting annoying. I've tried removing the gradle and .gradle folder, removing the .idea folder and then rebuilding the project. I don't know what to do anymore.
How do I keep this from not happening, is it something I have to do all the time everytime I see this error.

Make sure than only ONE of your activities has the LAUNCHER and MAIN properties in your Manifest file. This file can be found under Android Project view: app > manifests > AndroidManifest.xml. The one you want to boot in is the one that should have these properties.
Like this:
<activity
android:name=".Splash"
android:exported="true">
<!--This will be the starting activity you want-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true"/>
NOT like this (2 activities in the manifest both have:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
):
<activity
android:name=".Splash"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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>

Related

Android studio installing APK on phone but can't find the app

I am new to Android Studio and I am trying to deploy an APK to my mobile device in order to test the app. I build the APK successfully but when I install the apk of the app in my device I couldn't see it or cannot be open. But I can see the apps in the app manager showing that I installed it.
here is the code in my manifest file.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Pasig NutriCare"
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.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Looking for help.
Thanks in advance.
Did you checked Sort / Alphabetical / Custom ?
Also Check AndroidManifest.xml
Main Activity Should Contains :
Like :
<activity android:name=".SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
So change .SplashActivity to that you want And Remember to place dot . before it as i did
if you use sub Package Name place it , For Example :
your package is : com.example.myapplication
you create sub package as : activities
so in AndroidManifest.xml you have :
<activity android:name=".activities.SplashActivity"
...
</activity>
Make sure you specify the launcher activity for the app in your AndroidManifest.xml file:
<activity android:name=".YOURACTIVITY" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Did you specify the launcher activity for the app (in the AndroidManifest.xml)? If all else fails, you can also install the app manually using ADB (android debug bridge)
To install manually, Run this command from terminal/command prompt
adb install path_to_apk

intent filter category android.intent.category.default Default Activity not found

<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen">
<activity android:name=".MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".AppListActivity"/>
</application>
here android.category.default is used to make this application as default launcher like google launcher but when running this application its throwing error default activity not found...i have tried restarting and invalidating cache several times. can anyone help me...?
you can use this,
<activity android:name=".MainActivity"
android:launchMode="singleInstance"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
Go to Edit Configurations. Within the General tab, in the launch options drop down, select nothing. Now run the app.
You can use Control + Shift + A on Windows or Command + Shift + A on Mac, and type edit configurations to open it.
Just specify activity to lunch in android studio. To do that click on run configuration -> Edit configurations.
In Launch Options pick Specified Activity and then select your activity.

Launch a Library Activity From Project Manifest

Hi I have an activity defined in my Library like so...
<activity
android:name="com.company.application.corelibrary.recording.DesiredActivity"
android:label="#string/title_activity_tracking"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I then want to use this library to launch with in another application which I am doing like so...
<activity
android:name="com.company.application.corelibrary.recording.DesiredActivity"
android:label="#string/title_activity_tracking"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
However when I am going to build it it comes back with...
[2013-02-27 12:41:33 - TestApplication] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.application/.corelibrary.recording.DesiredActivity }
[2013-02-27 12:41:33 - TestApplication] ActivityManager: Error type 3
[2013-02-27 12:41:33 - TestApplication] ActivityManager: Error: Activity class {com.company.application/com.company.application.corelibrary.recording.DesiredActivity} does not exist.
com.company.application is my project package.
com.company.application.corelibrary is my library package.
I have included the library in my project.
What am I doing wrong?
ADDITION
I just renamed my library project's package name to something different than that of my project as I thought maybe as they were similar the project may look in it own source for the class but this did not work either.
in my application, i have wrote activity in manifest like:
<activity android:name="MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
i have also declare another activity (which activity belongs to my library) in the manifest as:
<activity android:name="com.facebook.LoginActivity"
android:label="#string/app_name" />
hope this will help u.
N.B:
u should not use
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
for two activity in a manifest.
I thought I would answer my own question. The other answers may be valid but this is what solved mine.
Before my activity declaration in the new projects manifest I had the following which was causing issues.
<uses-library
android:name="com.corecoders.st.corelibrary"
android:required="true" />
I removed that, cleaned and rebuilt the project and it launched fine.
I have solved this issue by implemeting he solution io.card does in their library. By wrapping with the application tags the activities into your library manifest.
<application>
<activity
android:name="com.eckoh.eckohroute.ActionConsumingActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="#style/Theme.Dialog.ActionActivity" />
</application>

No Launcher Activity found with .Launcher in Manifest.xml already included?

I am trying to run a source code I've found online for android. When I run it, it gives me:
No Launcher activity found!
The launch will only sync the application package on the device!
Performing sync
I already have in my Manifest.xml the following:
action android:name="android.intent.action.MAIN"
category android:name="android.intent.category.LAUNCHER"
What could be wrong? The weird thing is that it worked once. And then when I ran it again it gave me needs to force the application.
It is not a duplicate question because I've read that everyone is suggesting to place those in the Manifest.xml.
I think you need to define a launching activity. For example in my app
<activity android:name=".Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have defined which activity is started on app start.
please make sur to add android:exported="true" it will be like that
<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>

Android Apk generating multiple files after installation on System (Mobile)

My apk file generating multiple files after installation on the system as shown in screenshot. Please help me, what to do??
Most likely this is one App having multiple activities marked as action=MAIN and category=LAUNCHER:
<activity android:name=".ExampleActivity1" android:icon="#drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ExampleActivity2" android:icon="#drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
See also this SO question: Two main activities in AndroidManifest.xml

Categories

Resources