Android Studio Not Finding Main Activity - java

I created a new class in my project called UserTypeSelection.java and wanted to set it as the main activity which launches when I run the app. I've changed the manifest file to contain an intent filter and also tried editing the configurations to set it as the default activity, however I keep receiving the error:
Error running app: The activity must be exported or contain an intent-filter
My manifest file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name=".RegistrationActivity"></activity>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>
How can I resolve this issue. Any help is appreciated, thank you.

You are closing your activity xml tag before you have specified the IntentFilter.
Change your declaration to this.
<activity android:name=".UserTypeSelection" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

UserTypeSelection must be activity and it must be using intent filters you have not closed activity after intent filter it is closed before.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegistrationActivity"/>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>

Related

INSTALL_PARSE_MANIFEST_MALFORMED error in android studio

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.sudoku">
<uses-permission android:name="android.permission.INTERNET" />
<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">
<meta-data
android:name="com.google.android.actions"
/>
<activity android:name=".GameMenu">
<intent-filter>
<action
android:name="android.intent.action.MAIN"
android:screenOrientation="landscape" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar" />
</application>
</manifest>
I have this error that won't go away and I can't figure out what's wrong.
I checked my code and nothing is capitalized or mistyped. what is wrong with this document or is there another document that may be causing the error?
meta-data elements must have a value or a resource attribute, name alone is not enough.

how to fit xml file for all screen size of android phone?

I have created an android application. my app is currently working fine. but when i install this app to other device like 3.7" display size phone, some of activity's text view, button etc will cut. i want to make this auto for every screen size.
can you please inform me that how can i do that easily without bugs?
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.gurujibd.bornomala.alphabet">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
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:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SorBorno"
android:screenOrientation="landscape" />
<activity
android:name=".BenjonBorno"
android:screenOrientation="landscape" />
<activity
android:name=".ShongKha"
android:screenOrientation="landscape" />
<activity
android:name=".PoriChiti"
android:screenOrientation="landscape" />
</application>
</manifest>

Intent activity class not working

hey guys so im having a problem when trying to run the emulator of my application on android studio. this is the error im getting:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.dre.appli/com.example.dre.appli_app.LoginActivity }
Error type 3
Error: Activity class {com.example.dre.appli/com.example.dre.appli_app.LoginActivity} does not exist.
ive tried everything that people have suggested to no avail. here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wheretas.appli_app">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CreateAccount"
android:label="#string/title_activity_create_account"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="app.createaccount" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I suppose your LoginActivity has a package com.example.dre.appli_app.LoginActivity
But your manifest's package is different:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wheretas.appli_app">
...
Try to set it com.example.dre.appli_app

Strange behaviour of an alphaApk's shortcut

I have noticed that my application that is published to an Alpha test has a strange behaviour... The shortcut is launching the MainActivity again. Everything is working fine when it's installed via generated .apk
My Android-Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.YYY.XXX">
<application
android:name=".Infrastructure.XXXApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".activities.MainActivity"
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=".activities.BaseActivity" />
<activity
android:name=".activities.SettingsActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.SavedResultsActivity"
android:screenOrientation="portrait"/>
</application>
</manifest>

Android: No Launcher activity found! Did check LAUNCHER

So most responses told me to check that there's an activity with the category set to LAUNCHER. I have 2 activities - one starting the other, and 2 .xml layout files (for each of the activities)- I get the "No Launcher activity found" when trying to run on emulator.
This is my manifest-file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dk.orbliners.workout"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="dk.orbliners.workout.MainActivity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="SecondaryActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="dk.orbliners.workout.SecondaryActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
For your main activity you need something like this:
<activity
android:name="MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources