I have errors in my android manifest file:
Error:Cannot read packageName from C:\Users\brandon\AndroidStudioProjects\MineDodge2\app\src\main\AndroidManifest.xml
Error:The markup in the document preceding the root element must be well-formed.
I tried to look on this website but the answers aren't working for me.
<?xml version="1.0" encoding="utf-8"?>
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.brandon.MineDodge" >
<application
android:allowBackup="true"
android:icon="#mipmap/redjet"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.brandon.MineDodge.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.brandon.MineDodge.Splash" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</application>
</manifest>
If you are using an old version of build.grade file, you should remove this code:
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
Then, Build > Clean Project
Note: If you see this code, you are using the old version
I got this error on Unity 2018 and i think it's a bug.
Fix for me:
Add packagename to Android Manifest in Unity project.
In my project path to manifest: Assets/Plugins/Android/AndroidManifest.xml
For example i got error when my Manifest file looks like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
</manifest>
It generated by Oculus Gear VR plugin by Unity. But it missed package name and must looks like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest package="YOURPACKAGENAME" xmlns:android="http://schemas.android.com/apk/res/android">
...
</manifest>
Replace YOURPACKAGENAME to Package Name of your project. It should be in Edit -> Project Settings -> Player -> Other Settings -> Identification -> Package Name and should looks like com.YOURORGANIZATION.APPNAME
Some peoples wrote, that manifest must looks like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest package="${applicationId}" xmlns:android="http://schemas.android.com/apk/res/android">
...
</manifest>
And they wrote that Unity will replace ${applicationId} on package name when build android application, but in my Unity 2018.1.6f1 it doesn't work and i think it's a bug too.
The error is really simple, and I'm rather dissapointed with the stack community to not have found it till now.
< manifest ...
should become
<manifest...
Basically, remove that extra space. That's what's causing the following error :
Error:The markup in the document preceding the root element must be well-formed.
Also, the intent-filter used for the MainActivity, must similarly be used for the second activity.
Hope this issue is resolved.
My problem was that I was trying to convert an old Eclipse project to Android Studio project where the manifest file is expected to be on a different location (along with other files). Specifically project\app\src\main
In response to Eldar Kurbanov who had this error in Unity & anyone else who finds this question after having the error when building with gradle in Unity.
This is not a Unity 2018 'bug' nor is it caused by something being missing from the Manifest pre-build. It's actually caused by the mainTemplate.gradle file missing the line:
applicationId '**APPLICATION**'
Inside the defaultConfig {} block of the android {} section. This will ensure the generated manifest has the package name inserted into it.
Yes manually inserting the package name into the main manifest will work, but it's much better to just use Unity's project settings to set the package name rather than hard-coding it.
If anyone else finds this question and they're using Unity then here's an example mainTemplate.gradle you can use for referencing: https://pastebin.com/hPs0uvkZ
why you mentioned <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> twice? Remove any one from those two.
Your second <action android:name="android.intent.action.MAIN" /> and
<category android:name="android.intent.category.LAUNCHER" /> are not allowed here.
I think
`
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.brandon.MineDodge" >
<application
android:allowBackup="true"
android:icon="#mipmap/redjet"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.brandon.MineDodge.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.brandon.MineDodge.Splash" />
</application>
`
That will be OK.
I had this in a multi-subproject project, caused by the subproject not matching the configure( clause in the top-level build.gradle.
Specifically I had
configure(subprojects.findAll { it.name.startsWith("pachymeninx") }) {
which did not match my new subproject called pachymen. But the Gradle build process issued no warning (that I saw) and instead gave "Cannot read packageName from AndroidManifest.xml" error for the pachymen subproject.
Thats simply because you either copied an already existing project and its files into your newly created project. Thereby causing Manifest conflict. Because the manifest copied belongs to the other project and its paths.
you need to recreated a manifest file in your own project file path and possibly manually copy the other project's manifest code into your newly created manifest file.
Check if your src file is named with some different name.....if thats the case then you might end up with this error....rename it to "src
check your manifest file should be at-> \android\app\src\main\AndroidManifest.xml
otherwise android can't find the package name in Manifest file from a specific location
In my case, the module level android manifest file was in the wrong location. It was inside src/java/ whereas it is supposed to be in src/
try this ,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.brandon.MineDodge">
<application
android:icon="#drawable/launchicon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/AppBaseThemeTP">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Splash"
android:screenOrientation="portrait"
android:theme="#style/AppBaseThemeTP" >
</activity>
</application>
</manifest>
The android:name="com.example.brandon.MineDodge.MainActivity" should be under <application>, not under <activity>.
<activity
android:name="com.example.brandon.MineDodge.Splash" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</application>
change it to--
<activity
android:name="com.example.brandon.MineDodge.Splash" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
Okay first of all what I am doing is trying to integrate my Android game which is fully functional and tested to be working code onto Facebook.
I have been following the Facebook tutorial on how to set it up for Facebook and have been using the Android SDK version of the support v4 file.
The problem I have been having seems to be a conflict between the two SDK's.
R cannot be resolved to a variable.
For example
MediaPlayer song = MediaPlayer.create(this.getContext(), R.raw.ironman);
R.raw.ironman is where the problem occurs, which is a reference to the raw folder in my resources directory, where the mp3 file ironman is found.
It uses the R class which is part of the Android SDK
I had my game setup this way and it works great until I try to add the features from the tutorial.
For example
if (user != null)
{
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
R.id.welcome
This uses the R class which is part of the Facebook SDK for accessing a control the way it looks.
Another thing I noticed was that it keeps deleting my Java files as well.
from what I have read on other posts on here this is due to problems with the XML file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.SmashEm"
android:versionCode="2"
android:versionName="2.1" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/thumb"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden"
android:name="com.example.SmashEm.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>
<meta-data android:value="#string/app_id" android:name=" com.facebook.sdk.ApplicationId"/>
<activity android:name="com.facebook.LoginActivity" android:label="#string/app_name"></activity>
</application>
</manifest>
Maybe I am going about this all wrong but I just thought I would give this a try.
Any help would be a appreciated and thanks.
Also I am pretty sure this is different then all the other threads I read so far but I could be wrong since I am not an expert in Java.
I'm trying to complete this tutorial from the Android Page http://developer.android.com/training/basics/firstapp/starting-activity.html But I Eclipse throws this error: "No resource identifier found for attribute 'parentActivityName' in package 'android'" I have included the android-support-library.
Here is the whole AndroidManifest.xml code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
android:parentActivityName appears first in Android 4.1 (API level 16). You need to have the latest 4.1 SDK to compile this.
To add to David Wasser's answer, if you use Eclipse and have the correct SDK library installed but still have this error, it means that while the correct library is installed Eclipse does not use it for this project.
To change that, go to your project's Properties (right-click on its name in the Package Explorer and it's the last but one option), select Android in the left hand column and you should have a list called Project Build Target. Then:
Select the appropriate target (Android 4.2.2 or Google APIs for Platform 4.2.2 in this instance)
Save your Manifest file (make a trivial edit if necessary)
Once it is saved Eclipse will process it and those errors should disappear as Eclipse finds the resource identifier in its new build target.
This error will also happen if you don't have the exact version of the SDK that the sample app uses as it's build target. Following the same steps as Julien describes above and choosing an SDK you have locally will fix it.
In IntelliJ IDEA, you need to change in Platform Settings->SDKs->Android something->Build target TO 4.1+.
If you don't see the option, you need an SDK version 4.1 or higher (API level 16+).
So this is my Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxxxxxxxxxxxxxxx"
android:versionCode="3"
android:versionName="1.02">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<activity
android:name=".XXXXXXXXXActivity"
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=".XXXXXXXXXXXXXXXX"></activity>
</application>
</manifest>
Each time I upload to the android market, I get the error:
The server could not process your apk. Try again..
I previously uploaded a few APKs, but now I decided to downgrade my app, because it works on 2.1, previously it was on minimum 2.3. And since i've changed the minSdkVersion it doesn't want to upload anymore.
Looks like Android market is down. If you look carefully, you will see that upload does not even happen. So that error message is misleading you. Lets wait till Google resolves this.
#o2genum
I reported the problem here:
https://support.google.com/androidmarket/developer/bin/request.py?contact_type=bugs
(under "problems with the developer console")
And sent them the URL to this report
Edit:
Just saw this in the console:
22 February 2012: Application uploading and editing issues.
We are aware of issues with uploading and editing applications in the Android Market Developer Console. We apologize for this inconvenience and are working to fix this as soon as we can.
All layouts and button references mentioned in my java files all have warnings on them. The warning is always, button or layout cannot be resolved to a variable. I asked other developers for help on this and I was asked to remove the import android.R;. I was told it's not needed.
I did this and now all the R'S throughout my project have that same warning, I seemed to have traded one problem for another.
is there a way I can manually change the lines in the R.java file in gen/ because all layouts are in place in the layout folders and all buttons in the xml files have android:id:#+id/ I don't know what I have to do for Java to read its references so I can get past this hump.
Manifest
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ZohanActivity"
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=".MacAttack"
android:label="#string/app_name" >
</activity>
<activity
android:name=".ConsultationReq"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
First of all are you sure it's a warning? or is it an error?
Secondly, never modify the R file, because it is generated automatically. So all your modifications will be lost.
I would have to guess it's an error and not a warning. Here is what I propose to you:
Clean your project and rebuild
right-click the error, click on quick fix and choose "import package_name.R"