Error parsing XML: unbound prefix with Toolbar sdk 21 - android

So, I installed the latest SDK 21 Lollipop release. I was having the actionbar activated with icons on in, and I am trying to recover it back using the new toolbar feature... but it seems not working properly. Basically I am following the information provided here
Basically, you need to create a toolbar instance in the layout. So did I:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/myapp_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="20"
android:background="#drawable/action_bar_myapp" />
However, this is creating and error message at the second line with the error message "error: Error parsing XML unbound prefix".
When this error is happening (like in here) is usually due to having a wrong sintax, I copied/pasted directiyl from the webpage, also I made a simple test. By removing all android tags, the problem is still present.
Probably is something very simple, but I am stucked. Any idea?

You have to declare the android namespace.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
....
/>

Related

Layout that appears and disappears completely when the application is launched

When the application is launched, my layout is displayed for a very short second and then disappears. As a beginner in Kotlin, I don't understand why it produces this result.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="univ.master.kotlin.weather.city.CityFragment">
<fragment
android:id="#+id/city_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="univ.master.kotlin.weather.city.CityFragment"/>
</LinearLayout>
It's just a message from the preview window telling you that it can't show a preview for the fragment tag due to not knowing what kind of fragment you'll insert. When you run your actual app, the fragment will render fine.
try to add :
tools:layout="#android:layout/YOUR_LAYOT"
<fragment
android:id="#+id/city_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#android:layout/YOUR_LAYOT"
android:name="univ.master.kotlin.weather.city.CityFragment"/>
Thank you for sharing your xml and java code. If you tried everything and still layout is not appring it is just because of android studio is not able to catch you .xml code not to worry.
You can Select all xml code ctrl+A>ctrl+X>ctrl+V Don't ask me how.
I don't even know how but it works for me. You can also try this because this is the android studio universal rule
Rebuild project or Clear catch and restart
Hope it helps

How to fix android...ViewPager in Android Studio

I currently making a messaging app for my school project. I'm just starting mobile development this semester. Currently have run into a problem where when I add android ViewPager my activity_main.xml shows:
On the preview of the activity_main.xml
android...ViewPager (in blacktext in grey brackground)
For further explanation:
Anyway I was just thinking of following along to a tutorial because i'm stiil not that capable enough to code but are proffessor still told us to make an app even though his not really teaching that much. That's why i dont understand anything at all.
I just went to this tutorial and decided to use it for my whole project since i dont know anything at all.
So I went and watch and followed along a playlist on how to make a messaging app on this youtube channel Coding cafe, this is currently the video I'm watching and following:
https://www.youtube.com/watch?v=3Am-iad_Gkg&index=5&list=PLxefhmF0pcPmtdoud8f64EpgapkclCllj
First Project:
The first few tutorials everything was fine but at video number 5
Ive' watch the whole video did everything he did but after running the app if you see on his video the tabs were working on his but not on mine I just saw the title of my app but the tabs were not showing at all.
I tried looking at my work then i saw my xml file and there goes the:
click to see image
On the preview of the activity_main.xml
android...ViewPager (in blacktext in grey brackground)
I didn't know what to do because i was stupid did not know what to search, I search android...ViewPager, viewpager in android studio not working but all i was getting was "how to make a appbartab" and other tutorials on how to make one but i was afraid since this project is due february I' really rushing.
New Project Redo:
Back to the problem so after that i did not know what to do so I went and redo the project. Followed his tutorial again then I noticed that my problem was in the viewpager itself in the xml file.
When I typed the:
android View pagerin my activity_main.xml
It showed this again:
On the preview of the activity_main.xml
android...ViewPager (in blacktext in grey brackground)
so I was like what do i need to do?
So in the "First Project:" I already finished coding and doing everything he did in the video really carefully and as said it did not work
In "New Project Redo:" my progress is up until this point (timestamp 3:16)
I was afraid of going further because this code (see it on the video timestamp 3:16)
Made my activity_main preview do this:
On the preview of the activity_main.xml
android...ViewPager (in blacktext in grey brackground)
I dont know what the problem is so I really need help.
This is my code, as i've said havent add the fragment or anything yet cause i redid the project my progress is still in video 5 (timestamp 3:16).
Refer to the video for more information some people also have this problem in the comments but there are no replies.
https://www.youtube.com/watch?v=3Am-iad_Gkg&index=5&list=PLxefhmF0pcPmtdoud8f64EpgapkclCllj
If anyone can help me then thank very much.
My activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent"
tools:context=".MainActivity">
<include
android:id="#+id/main_page_toolbar"
layout="#layout/app_bar_layout">
</include>
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="#+id/main_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/main_tabs_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/appBarLayout">
</android.support.v4.view.ViewPager>
</RelativeLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity
{
private Toolbar mToolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar= (Toolbar) findViewById(R.id.main_page_toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("Chatterfly");
}
}
app_bar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_app_bar"
android:background="#color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.v7.widget.Toolbar>
I expect to have my app have an actual app bar where which has chats groups and contacts in it. Which right now isnt showing up when I run the app it only shows the Title of my app.
You need to add tab into your tab layout in order to show tab there by doing somehting like this tabLayout.addTab(tabLayout.newTab().setText(title));
As reference you can also look at this code, you can ignore the fragment adapter add the moment if you don't need it at the moment.

Xamarin.Android attributes showing "not declared"

I am new to Xamarin and especially xml, but I have run into a problem that I have not been able to resolve with any solution after hours of searching. I am trying to use the "android.support.percent" package to use percent margins on a relative layout. I have installed the proper NuGet packages to support it too. It worked for a little while, but now it has suddenly started giving me multiple warnings and messages throughout the file.
The first error is simply "The 'PercentRelativeLayout' attribute is not declared." This is just the name given to my starting xml tag. Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/percentRelativeLayout"
android:background="#000000">
Second, four warnings appear in the AndroidManifest with a similar message: "The 'http://schemas.android.com/apk/res/android:xxxx' attribute is not declared." where 'xxxx' is versionCode, versionName, label, and icon. The manifest file is not very extensive at all:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyProject.MyProject" android:versionCode="1"
android:versionName="1.0">
<uses-sdk />
<application android:label="MyProject"
android:icon="#drawable/Icon"></application>
</manifest>
On top of all this, there are 4 messages showing that say:
"Could not find schema information for the element 'manifest'."
"Could not find schema information for the attribute 'package'."
"Could not find schema information for the attribute 'uses-sdk'."
"Could not find schema information for the element 'application'."
What does all this mean and how can I get back to actually developing this app?
Figured it out myself, I am not very good at this. The tag must be .
The manifest errors, I don't know, but they seemed to resolve themselves.
The definition is:
<android.support.percent.PercentRelativeLayout>
You need to include the proper package name to this layout or else it will not be found.
As for the AndroidManifest.xml this looks fine from a first glance.

Uri is not registered for layout in test resources

I'm new at Android testing and I'm trying to test a custom view in an android library and i'm using Android Studio.
I found here : Android: How to test a custom view? that I should use ActivityUnitTestCase and a mock activity.
I have put my xml layout inside projectname/library/src/androidTest/res/layout and my test activity know my layout R id thanks to this : Configuring res srcDirs for androidTest sourceSet.
My issues is in the layout content.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<eu.custom.customView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
In my case, "http://schemas.android.com/apk/res/android" display in red with an error "URI not registered" and the IDE doe's not recognize my custom view if I add it in this xml.
Is there a way to have this layout working without putting it in production code ?
Thanks
Well, in my Eclipse IDE your code looks correct (there are no red lines) may I suggest you to download the ADT-Bundle again or use Android Studio? I think your IDE is corrupted or something in your settings is wrong. Also check if you have downloaded the up-to-date SDK build tools.

android bg prob

I am trying to add a background to my android project. Heres the code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backround="#drawable/awesome_face">
</RelativeLayout>
I spelled everything out correct but when i go into my graphical layout after saving and nothing shows up. Furthermore after i cleaned the project I now have an error on the
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
saying "no resource identifier found for attribute background in package 'android'" Anyone have ideas?
Just like ChristopheCVB said, your backgroud tag is missing a G.
android:backGround="#drawable/awesome_face">

Categories

Resources