Android Studio can't find activity - android

I am working with Android Studio 1.0 when suddenly, out of the blue I can not run my app on my phone because it is telling me that it can not find the default activity.
Changing the "default activity" to the specific activity I want to launch, ends in the error that apparently the activity I selected is not declared in AndroidManifest.xml.
Which also isn't true, because I did declare it in the .xml, I didn't remove it or add something new, it always has been there and now it doesn't want to work.
Thank you for reading and maybe answering / commenting. :D
Edit: This is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pack.aproject" >
<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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondPageActivity">
</activity>
</application>
</manifest>

you may need to refresh the IDE's cache.
File -> Invalidate Caches / Restart...

Related

Set default activity, execute before main Activity

I want to make register_activity is first run if application open. But, still MainActivity run first. Can anybody help me to fix this.
This is my Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.client18.dd">
<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/Theme.AppCompat.DayNight.NoActionBar">
<activity android:name=".register_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".signup_activity">
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
</manifest>
When I see your Manifest file I can not see any faults. I suggest to do followings.
1) Uninstall app in emulator / device if its exists, and then run application.
or
2) Rebuild project with cleaning ( Build > Clean Project )
P.S.
If you could practice signup_activity > SignupActivity it is nice and best practice.

The acitivity is not declared in Android Manifest

i had a problem, the Android Studio give me a warning which say:
"The acitivity is not declared in Android Manifest" this appear when i look on the Edit Configuration.
I see in another topic wich says that i have to put in androidManifest.xml
But i already did, and the Android Studio doesnt take it.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.drdower.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".AplicacionSencillaInicio"
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=".AplicacionSencillaResultado"
android:label="#string/app_name"/>
</application>
</manifest>
Which problem could be?
Thank u!
copy the code
delete the activity class
recreate one with same name
paste the code
Place your whole package path
com.example.drdower.myapplication.AplicacionSencillaInicio
Then clean your Project.
Also make sure you passed the correct java file name.

Android Studio doesn't recognize MainActivity though declared in AndroidManifest.xml

After pausing with work on an Android Studio project for a while, and then coming back and adding it to SVN, I can't get the project to run anymore; it seems to me that the original AndroidManifest.xml was probably lost due to a lack of proper "SVN ignore" rules, and as I created a new Android Studio project on a new machine, updated it from SVN and later commited (and also unfortunately already updated on the other machine I work on), it seems that SVN used the newer manifest file and maybe other files needed for a proper build of the project.
Besides the fact that in the current manifest file, there are several activites missing that I'll have to try to reconstruct there, I now have the problem that I always get the "Default Activity not found" error when trying to build. When I set it to .MainActivity (which is absolutely present in app/src/main/java/com.example.bla.logintest) it says "The activity 'MainActivity' is not declared in AndroidManifest.xml" and thus doesn't compile.
My manifest file now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE">
<application
android:allowBackup="true"
android:icon="#mipmap/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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</uses-permission>
</manifest>
Note: I already tried the solutions in [this similar question][1].
[1]: Default Activity not found in Android Studio "this similar question". Rebuilding and invalidating the cache doesn't get me anywhere. I also added
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
to my build.gradle, and this also didn't change anything.
I am aware that the parent to the other 2 activities is still missing and wanted to work on that problem next, but first wanted to have a working default activity.
Do you have any suggestions what I could try? I'm using Android Studio 1.3.2.
This should solve your problem.
You shouldn't write the tag inside the tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bla.logintest" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EditDB"
android:label="#string/title_activity_edit_diags"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
<activity
android:name=".EditAnswers"
android:label="#string/title_activity_edit_questions"
android:parentActivityName=".MenuActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.bla.logintest.MenuActivity" />
</activity>
</application>
</manifest>

stuck application at the same view even the class of that view is removed

Im working with an android application ,even if I change the names of classes at AndroidManifest.xml the application still work and installing on the tablet but the weird thing that even I removed the launcher activity from the manifest I still got it when I run the app the same xml view !!!
As an indication Im using Maven too.
I think the problem comes from Maven
this is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapps.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.myapps.android.project.login.Connection"
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="com.myapps.android.project.login.Connection" >
</activity>
</application>
</manifest>
I tried:
removing the R file
undeploying the application from the device with this comand:
mvn android:undeploy -Pandroid-15 -Dandroid.device=usb
Uninstall the application manually from the device
removing maven android folder from .m2/repository
I still got the same activity while deploying the application to the device
First of all, there is a little problem in your manifest: you are defining the same activity twice:
<!-- First time definition of "com.myapps.android.project.login.Connection" -->
<activity android:name="com.myapps.android.project.login.Connection"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Second definition of "com.myapps.android.project.login.Connection" -->
<activity android:name="com.myapps.android.project.login.Connection" >
you should remove the second one, it doesn't make sense to have a duplicated definition.
Did you change the Connection.java and/or Connection.xml and nothing hapened?

app appears in Manage Applications, but not on the main menu

I'm using Eclipse to make an Android app. I've used it before and not had this problem. The console says everything installed ok, so I'm a little confused. I'm not sure what is relevant from logcat, but I can post it if you think that would help.
I've restarted Eclipse, ADB, the emulator, and the Mac several times in various orders and nothing has helped. I know it must be something simple but I haven't played around with this in a few months.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyser.pinpoint"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
</application>
<activity android:name=".pinpoint" android:label="pinpoint">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Your Activity needs to be inside of your application tag in your manifest
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity android:name=".pinpoint" android:label="pinpoint">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
It's a similar issue to this:
Unable to start Service Intent
Your <activity> tag needs to be in the <application> block.
Is it possible your manifest does not refer to any activities? If you install an app with no activities in the manifest you will get this behavior.

Categories

Resources