How to fix the error code on android 'MainActivity' not declared - android

Error running 'app': The activity 'MainActivity' is not declared in AndroidManifest.xml
I've been getting this error code about 12 hours ago and trying to fix the problem. It seems to be related to package or activity on the codes: so here's what I've come up with
<activity android:name="com.dot.forklift.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Sync grandle and invalidated caches didn't work out for this matter; also, clean project didn't do much for this.
Even after those, the program is neither able to detect the activity nor to run properly. Keep sending the exact same error code as above.
I don't know where to research anymore and hard stuck on this same problem, please help me out.

Related

Android Studio : Error running 'app' Default activity not found

I'm new to android studio and doing my first project. I made changes to my layout xml file after which getting the above mentioned error. i didn't add any new activity and also the android manifest.xml file has default activity mentioned.
I have tried to invalidate the cache and restart the Android studio but still the error exists and I'm not able to execute my program.
You can configure it from "app" -> "Configurations"
In this scenario You have missed by telling the manifest about Which activity to run, Like I have Removed these Lines From Menifest
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This error will accour, Just add the above Lines in menifest and Your error will Gone.
Like I have tested By removing the above line for Yourself from Menifest I face the Error just Like You..
Here the main Activity will be the One You want to start First After Installation Of Apk

Default activity not found Android Studio - repeating error

I've just started having this issue today on a project that has been working for months, without changing the manifest at all I get this error when trying to run the app. My main activity is defined in the manifest as:
<activity
android:name=".MenuActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I've tried all of the solutions I've found from previous questions to unfortunately no effect.
The weirdest part of this is if I hit "sync project with gradle files" 5-10 times one right after the other, it will start working for a few runs and then i'll need to repeat to fix the problem again. Anyone experienced this?
You can edit your configuration as below Edit Configurations:
Then select your Default Activity as below Launch Options:

Default activity not found android studio?

I have a problem that I have seen that a lot of other users have.
When I try to run my application I get an error that says that I have no default activity.
The weird thing is that in the first one everything works fine but on the second one it starts doing problems.
I've tried to do
"File -> Invalidate Caches / Restart..."
but it works for only one run (sometimes doesn't work at all).
Also when I run the same code on another computer it works perfectly every time.
I tried reinstalling android studio but that did not help.
Ensure you have at least one activity being the launcher in your manifest
<activity
android:name="com.your.package.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>
if that does not work,go to files> Sync Project with gradle files

Error running 'app': Default Activity not found

I do find multiple solutions on here, but non of them work for me...
I cloned an ixisting Androi project, it worked perfectly fine, I added and changed some code, added a fragment and a resource for the fragment. While doing this, everything kept working fine, but suddenly I got this error...
I tried several things:
1. In "Edit Configuration" changed the "Default Activity" to specific activity, but than I get the error that it is not specified in the AndroidManifest.xml (which it is).
2. I tried using the full package path in the manifest ("com.example.something.ActivityLogin" instead of ".ActivityLogin")
<activity android:name=".ActivityLogin"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Invalidated caches and restarted
Tried reinstalling Androi Studio
And now for the craziest one:
5. Removed the entire project, pulled the master from git, and the issue is still present!
Also, I did not touch the AndroidManifest nor the ActivityLogin at all, I did not refactor anything...
I'm not sure where to look further, I'm guessing it is an Android Studio (3.2.1 from October 9, 2018) related issue? Also, another project keeps running just fine...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Build-Clean Project or Build-Rebuild Project
Well, I knew it wasn't my code, it was Android Studio...
This did the trick: https://stackoverflow.com/a/52680053/5427848

Crash on ActivityThread.handleBindApplication when updating AndroidManifest.xml, rollback still crash

I had a warning Exported receiver does not require permission in my AndroidManifest.xml about this receiver :
<receiver android:name="org.thieftracker.SmsReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.ACTION_BATTERY_LOW"/>
<action android:name="android.intent.action.ACTION_BATTERY_OKAY"/>
</intent-filter>
</receiver>
I understand the problem, I fix it by changing first line with :
<receiver android:name="org.thieftracker.SmsReceiver" android:enabled="true" android:exported="false">
But it crashes on debug launch.
I roll back by removing the android:exported="false"
but it still crashes on : ActivityThread.handleBindApplication(ActivityThread$AppBindData) line: 4070
I tried to clean the project, it still crashes.
My only solution it to delete my whole workspace and copy back a backup !
I guess it comes from the Eclipse IDE.
Any idea ?
UPDATE :
Found it !
I forgot to put a permission in my AndroidManifest (WAKE_LOCK).
I still don't understand why it used to work when the permission was missing. I guess it comes from some cache/update stuff over AndroidManifest.xml
I also lost a lot of time because I did not know how to use LogCat and DDMS view. About that, I still don't know where to find the stack trace !
I put back the bug, and I am still fighting with IDE to find again the stack trace with the magic
java.lang.RuntimeException: Unable to create application org.thieftracker.ThiefTracker: java.lang.SecurityException: Neither user 10029 nor current process has android.permission.WAKE_LOCK
Where the hell did I get it ?!
I am not sure try this:<receiver android:name="org.thieftracker.SmsReceiver" android:enabled="true" android:exported="false">

Categories

Resources