Running Android Studio app on Device gives me Default Activity Not Found - android-studio

I'm currently Android Studio 2.3.3 and S6 Edge to test my app on the real device but it keep giving me an error saying Error running app: Default Activity Not Found.
I have
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and tried restart Androdi Studio but error is still there.
Does anyone know how to figure this out?
Thank you

Put your MainActivity Theme inside MainActivity.
Something like:
android:theme="#style/AppTheme.NoActionBar"

Make sure it's inside the application node.
Like this:
<application
android:name="YOUR_APP_NAMESPACE_HERE"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

1st Step
Select 'app', then 'edit configurations'.
enter image description here
Select "nothing" in launch.

Related

I get a warning saying: is not an activity subclass or alias

What does the icon next to MapsActivity mean?
When I run the app, it says MapsActivity is not an Activity subclass or alias.
That is my mainfest?
<application
<activity android:name=".MapsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Android Studio is showing an error when I press the run button

I have been following a YouTube tutorial on 2D Game development and when I pressed the run button to check, it shows:
Error runing "app": Default Activity not found
Also it shows an error on AndroidMainfest.xml if I use landscape instead of fullsensor:
<activity android:name=".GameActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.noActionBar"></activity>
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.noActionBar"></activity>
Use intent-filter:
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And why #style/AppTheme.noActionBar? Use #style/AppTheme.NoActionBar.
See also "Default Activity Not Found" on Android Studio upgrade.

Failed to parse XML in Android Manifest after update

I have an app I was working on a few months ago. Today I opened it again in Android Studio 3.4 and when syncing it asked if OK to upgrade to the current version of Gradle and the Gradle plug-in. I agreed and I now get an XML parsing error in the manifest.
The manifest is here, I added a comment to signal where I get the error:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.schalkx.alarmapp01">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<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.AppCompat">
<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=".SetAlarmActivity">
android:label="Alarm Settings"
android:parentActivityName=".MainActivity" <!-- *** I GET THE ERROR HERE *** -->
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity android:name=".ShowClockActivity">
android:label="Desktop Clock"</activity>
<receiver android:name=".AlarmReceiver" />
<activity
android:name=".UserResponseActivity"
android:label="#string/title_activity_user_response" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
I did some tests adding a new activity and I noticed that the syntax is now generated a bit differently, and would start like this:
<activity
android:name=".SetAlarmActivity"
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"
....
That is, the ">" is not added at the end of
<activity android:name=".SetAlarmActivity">
but later on. Trouble is I haven't been able to get the syntax right.
Any ideas what's wrong?
Thanks!
It should be
<activity android:name=".SetAlarmActivity"
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"> //<--Notice
Instead of
<activity android:name=".SetAlarmActivity"> //<--Notice
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"

How to fix problem with run app on android studio?

I Work with Android Studio 3.2 and i have problem with Run app because not working and get me "App Default Activity not found"
Problem -> https://imgur.com/a/2Q0SGUq
This code is manifest for app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.erik.firebaseauthdemo">
<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=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".ForgetAndChangePasswordActivity"></activity>
</application>
</manifest>

Error while generating APK

I'm trying to generate an APK from Android Studio for publish it on the play store.
Now when i generate the APK i got this error:
I can start the app but "Generate APK" not work and for avoid this error i copy my Facebook App Id from my string.xml to my manifest:
android:value="2132153153153535"
Instead of:
android:value="#string/facebook_app_id"
Now i can generate the APK but when i launch my app from the playstore i got this error:
Unable to start activity ComponentInfo{com.stable.giamma.sushichallenge/com.stable.giamma.sushichallenge.MenuActivity}: java.lang.IllegalArgumentException: Both context and applicationId must be non-null
That i can resolve by reversing the modify that i just did.
But if i do so i can't generate the APK again.....
What is the right way for handle the "facebook app id" and generate the APK?
p.s: i have 2 string.xml (one is for english and the other for italian language) dunno if create some problem...
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.asd.appname">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
o
<application
android:allowBackup="true"
android:icon="#mipmap/asd"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" /> //THIS IS THE STRING THAT I MODIFY FOR AVOID THE FIRST ERROR
<activity
android:name="com.asd.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.NoActionBar" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.asd.MenuActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.asd.SushataActivity"
android:label="#string/sushata"
android:parentActivityName="com.asd.MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.asd.MenuActivity" />
</activity>
<activity
android:name="com.asd.Sushata2Activity"
android:label="#string/sushata2"
android:parentActivityName="com.asd.SushataActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.asd.SushataActivity" />
</activity>
<activity
android:name="com.asd.Leaderboard"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
I added:
tools:ignore="ManifestResource"
The correct code is:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"
tools:ignore="ManifestResource"/>
Now seems work I found this stackoverflow post helpful: link

Resources