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>
Related
I've copied a jar file into my project's libs folder. Usually it will show me all of the files contained therein. For this one JAR file, it won't display the class file embedded inside, but does display a manifest file.
Let's say the jar is custom-unity-activity.jar and the directory structure is com\custom\activity\custom-unity-activity.class. As far as Android Studio gets is "com.custom" and then goes no further. The compiler also can't resolve symbols defined in the class file, so it definitely isn't reading it in.
I know this jar file is valid, because it has been used successfully under a different build environment.
It's really hard to import Unity's project into an existing Android Project. The solution is to do it the other way around instead.
Build the Android Studio project as to jar or .arr plugin then place in your Unity project at: <ProjectName>Assets\Plugins\Android.
If you want to load your Android Studio project activity, you must modify the AndroidManifest.xml to let Unity know that then place it at:<ProjectName>Assets\Plugins\Android.
Below is what the XML should look like. It will specify the activity name to load and will also tell Unity to allow you to use input events from your Android Studio project otherwise, Unity will steal those events. The manifest below assumes that the Android Studio activity name is "MainActivity".
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.casualcoder.plugin" android:installLocation="auto">
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name">
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
</application>
</manifest>
I am developing an android application and after moving around some libraries and adjusting my workspace so that it can sync with github I am now encountering a new error that I have not had in the past. Here is the print out in LogCat.
FATAL EXCEPTION: main
Process: com.exmple.loop, PID:1000
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.loop/com.example.loop.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "com.example.loop.MainActivity" on
path: DexpathList[[zip file "/data/app/com.example.loop-2.apk"]...
I can supply more if needed. I have checked stackoverflow for solutions and came across some that proved to be unhelpful. Here is the first question I found and here is the second. I tried the helpful solutions for both and nothing seems to work. Similar to the user in the first question, the exception is thrown before any line I write because it is failing to recognize my main activity as a class.
Here is my android manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loop"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:name="com.example.loop.LoopApplication"
android:icon="#drawable/loop_icon"
android:label="#string/app_name"
android:theme="#style/Theme.Loop" >
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity
android:name="com.example.loop.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:theme="#style/AppTheme" android:logo="#drawable/loop_icon" android:name="LoginActivity">
</activity>
</application>
</manifest>
If you look in your logcat it writes:
ComponentInfo{com.exmple.loop/com.example.loop.MainActivity}:
com.exmple.loop
I think it should be com.example.loop
Try remove this line and see if it works:
android:name="com.example.loop.LoopApplication"
Change your activity tag to this and it will run:
<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>
There are many causes to this. I'll try to name as much as I can.
1.You tryed to add the library in your Java Build Path and not in the Android libraries.
rigt-click on your project> properties > Android. At the bottom there is a place for Android libraries.
2.Right-click your src folder>Build Path > Use as Source Folder
3.Right-click you src folder> Build Path> Configure output folder > set projects default output folder
4.Right-clikc project > Java Build Path > Order and Export > check Android Private Libraries
(You CAN'T have any library in Android Private Libraries and in the outside at the same time)
5.If you have set the project to use Maven and removed it after. Delete the bin folder and the pom.xml
6.Check if you R file is being generated. Delete it and see if it rebuild. If not look in your manifest or xml files for any error.
7.Check that Build Atomatically is checked.
Hope this help, I have had this that problem many times, and each time it was something else.
Good luck!
Edit: there is a 8 cause but this is not your case. Its if you forget to add the class to the manifest.
So after trying every bit of advice given to me I decided to create a new Android Project and copy all the files from the old project the appropriate folder in the new project. While this took a little bit of time that could have probably been shorter if I had messed with the original project some more, ultimately it did fix the error I was encountering and the project now runs.
I was initially trying to add a splash page to my app, and followed a tutorial on how to do so. However, now every time I load my app, it does to a white screen for a few seconds before saying "Unfortunately, [App] has stopped."
I was unable to find a way to copy LogCat, so here's an image of the errors which appear:
Also, here's my Manifest XML:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bipbapapps.leagueclickerapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
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=".MainClass"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.bipbapapps.leagueclicker.CLICKER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Deleting the splash Java and activity from the manifest does nothing to help now (and when I deleted it, I did revert MainClass to .LAUNCHER .
Can anyone make sense of the list, and/or help me run my app again?
From the logs, I found that you should
Call the requestFeature before setContentView();
The error says it you are calling setContentView() before requestFeature(). Don't do it.
LogCat should show you the problem. Click on all the error lines in the LogCat until you will be redirected to the problem.
I, myself, found that your problem could be at: Splash.java, line 19
Go check it out, hope it helps!
I have an Android xml file that includes splash and one another activity ım planıng to pass one to another while using ınytent in this context I created a default and launcher category
but eclipse is giving me error that: Tag <category> attribute has invalid character
(actually there is no invalid character)
here is my xml code
(boldline is the line that error occurred)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tesbih"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.tesbih.TesbihMainActivity"
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.tesbih.Splash"
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>
here is also my logcat
Description Resource Path Location Type
The value of the local variable timer is not used Splash.java /Tesbih/src/com/tesbih line 15 Java Problem
Tag attribute name has invalid character ' '. AndroidManifest.xml /Tesbih line 21 Android AAPT Problem
the reason of thıs problem is a bug that bundle has. if you save everythıng and exit
then when you open agaın you should go your xml fıle after makıng anychanges on the name of android name you can save and re exit again when you open your eclipse and android manifest your error sign will be lost
I'm very new to Android programming and I've been trying to figure out why my app is force-closing on a button-click. I've narrowed it down to a few things.
One question; Is it possible to have more than one <application> tag in the manifest xml?
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dummies.android.beergoggles"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<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="Result" android:label="#string/app_name"> </activity>
</application>
<application android:name="MyApp"
android:icon="#drawable/icon"
android:label="#string/app_name2"></application>
I've been researching, but found only a vague post about creating a new manifest file for a new application. The MyApp application is just an app for a "global variable", since I guess there's no way to do that without a new application.
Here is the code for MyApp in case it helps:
import android.app.Application;
public class MyApp extends Application{
public static int resultCount;
public int getCount(){
return resultCount;
}
public void setCount(int c){
resultCount = c;
}
}
Any help would be much appreciated.
According to documentation manifest file with only one application element is valid.
Only the <manifest> and <application> elements are required, they each
must be present and can occur only once.
What I think you want is to use your custom Application as the main Application.
So you dont add a new <application> but just specify its name to the main <application>(you need to specify its full package).
<application android:icon="#drawable/icon" android:label="#string/app_name" android:name:"com.mypackage.MyApp"> <!-- Added the android:name -->
<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="Result" android:label="#string/app_name"> </activity>
</application>
See info here
Only the 'manifest' and 'application' elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful.