Android Studio is acting weird today. I was developing an application and until today it was running fine but now, first it crashed my HTC Drivers and adb stopped working.
I managed to fix it but now whenever I run my application it keeps on giving me Error Running App: Default Activity not found.
It is becoming annoying. I have already google it but most of the answers referring to File > Invalidate Caches & Restart... > Invalidate & Restart
. I tried this solution. But again on running the app right after Installing APKs...
, Android studio again throwsDefault Activity Not Found.
Here is my Manifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/base_logo"
android:label="@string/app_name"
android:roundIcon="@drawable/base_logo"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<service
android:name=".application.classes.map_manager.FetchAddressIntentService"
android:exported="false" />
<activity android:name=".application.activities.MainActivity" />
<activity android:name=".authentication.activities.NumberActivity"/>
<activity android:name=".authentication.activities.PasswordActivity" />
<activity android:name=".authentication.activities.NameActivity" />
<activity android:name=".authentication.activities.VerificationActivity" />
<activity android:name=".authentication.activities.LoginActivity" />
<activity android:name=".application.activities.MapActivity" />
<activity android:name=".application.activities.SplashActivity" android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I have already provided the Sources directory in build.gradle. Sometimes it just works fine. Most of the time after restarting PC, it runs for the first time completely fine. But for the next run, it keeps giving "Default activity not found"
Default Activity: SplashActivity.kt
package com.kingstechnology.user.buraq_rider.application.activities
import android.content.DialogInterface
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.provider.Settings
import android.support.v7.app.AlertDialog
import android.util.Log
import android.widget.Toast
import com.kingstechnology.user.buraq_rider.R
import com.kingstechnology.user.buraq_rider.application.classes.AppConfiguration
import com.kingstechnology.user.buraq_rider.authentication.activities.NumberActivity
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
}
override fun onResume() {
super.onResume()
checkInternetConnectivity()
}
/**
* This method will check for internet connectivity,
* On Success: This method will redirect to UserManager page if user is not Logged In
* On Failure: This method will ask to turn on wifi and repeat the proccess
*/
private fun checkInternetConnectivity(){
if (AppConfiguration.isInternetConnected(this)) {
// If user is logged in take it to Map Activity
if (AppConfiguration.isUserLoggedIn(this)) {
// Go To Map Activity
}
// If user is not logged in
else {
val intentForNumberActivity =
Intent(this@SplashActivity, NumberActivity::class.java)
startActivity(intentForNumberActivity)
finish()
}
} else {
// Ask user to connect to internet
AppConfiguration.askForInternet(this)
}
}
}