Elements not allowed here in android manifest file - android

I made a new project in Android studio, and this is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cro.perger.rajcica" >
<application
android:allowBackup="false"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".rajcica" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When I build my file I get few gradle errors, and I get this debug/manifest file open:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cro.perger.rajcica"
android:versionCode="10"
android:versionName="2.0.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name="cro.perger.rajcica.rajcica" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I get this errors:
URI not registered
element not allowed for (versionCode, versionName, icon, allowBackup, theme, supportsRtl)
Don't know how to resolve this, because many of this attributes are deleted from my manifest file, but not from debug/manifest file :(
Please help

If you removed those lines from the manifest, but they are still in your debug, then it sounds like your manifest is in the wrong folder. Something changed in your directory structure maybe and you did not realize or intend for that to happen.
Get the manifest in the right folder and make sure that you are editing the correct one.
See this related post: Why is Android Studio reporting "URI is not registered"?
It also could be that you are setting them in your build.gradle file - check there.

Related

How do I add a final newline in my manifest.xml in Android Studio

I get an error in my manifest.xml which I can't seem to solve.
The error is:
Manifest file doesnt end with an final newline.
The error occures right before the last </application>.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.matthias.w_seminar">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainMenu"
android:theme="#android:style/Theme.Holo.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Difficulty"
android:theme="#android:style/Theme.Holo.NoActionBar"
/>
<activity android:name=".GameNormal"
android:theme="#android:style/Theme.Holo.NoActionBar"
/>
</application>
</manifest>
Click on the word with the red line (that causes the mentioned error), then click Alt+Enter and choose
Un-inject Language/Reference
You can also try to copy your manifest content, delete original manifest file and create new one like this :

MonkeyRunner unable to use startActivity

The following is my AndroiManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<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>
I want to launch my app using monkeyrunner but when I give the command
device.startActivity(component='com.exmaple.helloworld/com.example.helloworld.MainActivity')
It doesn't start my app. Am I missing anything. I read Issues using monkeyrunner startActivity but still it didn't work.
Add android:exported="true" line for the activity in AndroidManifest.xml file
device.startActivity(component='com.exmaple.helloworld/com.example.helloworld.MainActivity')
have you tried fixing the typo (exmaple instead of example) ?
device.startActivity(component='com.example.helloworld/com.example.helloworld.MainActivity')
Have you tried device.startActivity(component='com.exmaple.helloworld/.MainActivity')?
You should change activity name in manifest, from:
android:name=".MainActivity"
to
android:name="com.example.helloworld.MainActivity"
then your script will work.

root element must be well-formed-android manifest

**my manifest file the error is listed below i think it has something to do with the repeated manifest side by side i can't fix it **
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.BinaryRelics"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="20" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Homescreen"
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=".Arcademode"
android:label="#string/title_activity_arcademode" >
</activity>
</application>
The error is on this line below notice how the 2 manifest tags are next to each other if i delete the first one it says that the application must be a direct child of the manifest if i delete the 2nd one it moves the error to the next line of code
</manifest><manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity
android:name="com.BinaryRelics.Arcademode"
android:label="#string/title_activity_arcademode"
android:parentActivityName="com.BinaryRelics.Homescreen" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.BinaryRelics.Homescreen" />
</activity>
</application>
</manifest>>>>>>>> Added
Why do you have two manifests and two applications defined? You may get away with two applications (I've never tried) but you can have only one root node and it must be 'manifest'
Delete the entire line in the middle
</manifest><manifest xmlns:android="http://schemas.android.com/apk/res/android" >
From the second defined application node take the <activity ...> ... </activity> out and move it inside the the first defined application.
Then delete the left over <application></application> from the end.

AndroidManifest.xml is getting corrupted when a new activity is created

When i create a new activity for my project, my new activity has errors, i think they are related to the androidmanifest.xml which get some weird lines at start and at end.
This are the lines that eclipse says that has errors
<<<<<<< Original
, >>>>>>> Added
And this is the entire androidmanifest.xml
<<<<<<< Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="moran.jonathan.pizzeria"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="moran.jonathan.pizzeria.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="moran.jonathan.pizzeria.Menu"
android:label="#string/title_activity_menu" >
</activity>
</application>
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name=".Menu"
android:label="#string/title_activity_menu"
android:parentActivityName="moran.jonathan.pizzeria.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="moran.jonathan.pizzeria.MainActivity" />
</activity>
</application>
</manifest>
>>>>>>> Added
What could be happening?
Thanks in advance
EDIT WITH USEFUL INFO:
Never try to create an activity called Menu, as it seems to be some kind of reserved word and this is why this problem appears
This is because you have merged a conflicted file in git. Remove those lines and remove the repeat code and commit again:
<<<<<<< Original
// (1) this is your original Manifest code
=======
// (2) this is the new code.
>>>>>>> Added
NOTE: Either remove (1) or (2) depending on you need. and remove the extra lines
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="moran.jonathan.pizzeria"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="moran.jonathan.pizzeria.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="moran.jonathan.pizzeria.Menu"
android:label="#string/title_activity_menu" >
</activity>
</application>

INSTALL_FAILED_ALREADY_EXISTS with two different package names

I have two manifests that I swap round when building different releases of my app. The manifests have different package names yet I can only build one on the device at a time. I really need both to be built. The project has no src files and uses an activity from a library.
Manifest one:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.pkgone" android:versionCode="01" android:versionName="0.1">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.test.Splashscreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Manifest Two:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.pkgtwo" android:versionCode="01" android:versionName="0.1">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.test.Splashscreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I've sorted it out! The issue was that the R.java file in the gen folder wasn't being cleaned so I just ran
ant clean
before
ant release
and it works great! Thanks to #enrmarc and #Roman Nurik for their help :)
I solved it. I had the same problem.
You need to change the "applicationId" in your build.gradle(Module:app) file
be aware that there will be two build.gradle files. Open the one with (Module:app)
then clean your project.

Categories

Resources