The acitivity is not declared in Android Manifest - android

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.

Related

"Could not identify launch activity: Default Activity not found" - Android Studio - no answers working

Whenever trying to run the app, getting the error:
"Could not identify launch activity: Default Activity not found".
I have seen a few other threads on the same issue, but the below solutions have not worked for me:
Invalidating gradle cache and re-running
Manually overriding in the edit configuration tab to select the default activity (it then says "The activity 'MainActivity' is not declared in AndroidManifest.xml" even though it is!)
Re-syncing the gradle files
Literally shuffling around the order of the activities in my manifest
Using the long name for my activities, but doesn't make any difference
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mywebname">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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"
android:screenOrientation="portrait"
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=".ListenScreen"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
</activity>
</application>
</manifest>
```
As you can see, I have clearly declared the activities (my app only has 2 so far), and I've put the intents around the ".MainActivity".
This answer worked for me after trying so many other tweaks, just adding the package name solved my problems
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.name">
https://stackoverflow.com/a/72300233/8720836
You can only have to add the package name inside the manifest tag you can find your package name inside app.gradle file and you are good to go

Manifest XML not well-formed (invalid token) Android

So, I think I accidentally deleted something from the manifest, but I am using AIDE and I no longer have the option to undo it. I've looked through examples on StackOverflow and throughout the general Internet, trying to find the problem with the manifest, but nothing seems to be missing. The error is showing after the android:label line in <activity>.
Before supposedly deleting something, the app compiled and ran as expected. Thanks to anyone that can help.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bitcoin.app" >
<uses-permission android:name = "android.permission.INTERNET"/>
<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>
</application>
</manifest>
It means there is a compilation error in your XML file, something that shouldn't be there: a spelling mistake/a spurious character/an incorrect namespace.
Check your #string file and XML file.
Eg: android:text="#string/hello";
a semicolon that shouldn't be there after this line

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>

change application's package name in manifest

I know this question has been asked many times, but I didn't find exact solutions which I would understand.
I have made a little game with android studio and I would like to publish it. But then I find out that I can't use package name "com.example". How do I change this to "com.MYNAME"?
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.MYNAME.APPNAME" >
<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:label="#string/achievements"
android:name=".Achievements"
android:parentActivityName=".MainActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.MYNAME.APPNAME.MainActivity" />
</application>
</manifest>
If I change package="com.example.MYNAME.APPNAME"topackage="com.MYNAME.APPNAME", there will be errors in android:name=".MainActivity", android:name=".Achievements", android:parentActivityName=".MainActivity" and android:value="com.MYNAME.APPNAME.MainActivity".
Thank you for help!
You need to change .java file package name also.
Then clean the project and build again.
Because .MainActivity is still in package name "com.example.MYNAME.APPNAME"
please do the following to change your package name to the new one
Right click on your project
Choose Android Tools
Choose Rename Application Package
Enter your new package name then click ok
Please check this out and change com to org and then you can publish your app
https://youtu.be/A-rITYZQj0A
You don't have to do anything manually, Just right click on the package name > refactor > rename. Everywhere in your project the project name will be changed :)

Android Studio can't find activity

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...

Categories

Resources