R not generated, XML file contains error but which XML file? - android

My R file is not generated after I clean my project. And according to my research on stack overflow, I think I have an error in my xml file but I dont know which xml contains the bug. I went through all of them including the AndroidManifest file.
Is there any way or tool to help me find out which xml contains the error? I have been stuck with this problem for like 10 hours. Please Help!
p.s
I have 2 different custom view where both have the same namespace (but uses in separate xml file), is that a problem?
AndroidManifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.packagename.appname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
<activity
android:name="com.packagename.appname.activity.SplashScreenActivity"
android:icon="#drawable/ic_app"
android:label="#string/app_name"
android:noHistory="true" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger" />
</activity>
<activity
android:name="com.packagename.appname.activity.MainActivity"
android:enabled="true"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.packagename.appname.activity.SelectActionActivity"
android:enabled="true"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
Problems View

Found the bug... I declared the same id twice in the ids.xml. I would like to share how I found which xml contains the error. So I copied out individual xml content and deleting them from the project to see if the R file would generated. For all the non-xml, I set them to not including into build path for the time being. Its not the best way to find a error but it is a way. Thanks for everyone who reply to question. Happy coding.

Related

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

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.

Tag <manifest> attribute package has invalid character ' ' Android Manifest

I am getting the error "Tag attribute package has invalid character ' '." in the Android Manifest, while there is no obviously invalid character. Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampl e.harounsmida.test2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.example.harounsmida.test2.app.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.harounsmida.test2.LoginActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.harounsmida.test2.RegisterActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" />
<activity
android:name="com.example.harounsmida.test2.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop" />
<activity
android:name="com.example.harounsmida.test2.UploadToServerActivity"
android:label="#string/app_name"
android:launchMode="singleTop" />
</application>
</manifest>
I don't understand where is the problem, Android Studio says that "File under the build folder are generated and should not be edited." although I didn't edit it.
Remove space from package name :
package="com.exampl e.harounsmida.test2"
After removing space :
package="com.example.harounsmida.test2"
For those who still can't solve this problem :
1 - Close Android Studio.
2 - Browse to your project directory.
3 - Rename the project directory name to something else.
4 - Open Android Studio and open your project (browse to the renamed directory) .
5 - Select Build --> Edit Flavors --> Type something like yourname.myapplication in application id textbox (avoid using non English characters or space)
Image
6 - Select Build --> Rebuild Project and you are good to go.
Please consider gradle file and see what you have given as applicationId, any name that you have given in applicationId will be copied from gradle file and pasted to manifest
Also see for space and extra character in package's value
Try this code
package="com.example.harounsmida.test2"
remove the space in your package definition because space is not allowed
After throwing the error as mentioned above, Android Studio opens the file "debug\AndroidManifest.xml". Note that the Manifest file for the project is "main\AndroidManifest.xml". I didn't notice initially and was removing the space from the former file (which Android Studio opens up).
Hope it helps!

Element type "application" must be followed by either attribute specifications, ">" or "/>" #2

I keep getting an error that says, "Element type "application" must be followed by either attribute specifications, ">" or "/>"."
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thenewboston.sammy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
I'm getting the error right below this:
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is the right form, see if you didn't close some tags.
<application android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
...>
<activity ...>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
As my friend said , check the right format
For me It was like this :
BEFORE :
<activity android:name=".DisplayMessageActivity" android:label="display_message_activity"
</activity>
AFTER:
<activity android:name=".DisplayMessageActivity" android:label="display_message_activity" >
</activity>
Then the error disappeared
In my case, a comment had been placed (by the build tools?) inside the application tag:
<application android:allowBackup="true"
<!-- android:debuggable="true" -->
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme">
After I removed the entire debuggable=true comment line - everything worked.
I just ran into this error for a completely different reason. For some reason Android Studio had replaced every instance of the string name with "name" (e.g. it wrapped them all in double quotes) in my XML. It completely broke everything.
I had to clear out the double quotes from everything, clean the project and rebuild it.
If you're a flutter developer and you're getting this exception you must know there are two AndroidManifest file in your flutter project. One is inside debug folder and another one is main folder. My main folder AndroidManifest is ok and well formatted but AndroidManifest in debug folder is not ok and not well formatted due to a git conflict.
you must fix this.

Importing android projects that do not have android manifest file

I am currently busy in designing a custom view for my major project. I ran through custom view tutorial provided at developer.android.com . I downloaded the associated sharable project because it gets easy to handle and understand the mechanism of the application when source code is in front of you. To my surprise, the project only contains two folders, src and res and there was no android-manifest file. I tried normal import method, import from existing code and createing new project from exsting android code, no luck with any of the methods. Here the link for the project.
Can somebody please explain to me how I can get it working ?
Can somebody please explain to me how I can get it working ?
Create an empty Android project. Copy in the res/ and src/ from the ZIP file. Modify the manifest to point to the activity class that you copied from the ZIP file.
Create a new empty android project. Copy all resources and source files to your project folder.
http://developer.android.com/guide/topics/manifest/manifest-intro.html.
Goto AndroidManifest.xml define activities and permissions accordingly.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package name"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="packagename.MainActivity"//your 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="packagename.SecondActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="packagename.SecondActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

Categories

Resources