3

I have had a problem with the following attributes app:RectLayout and app:Roundlayout, it gives errors in the xml, saying that there is

Multiple annotations found at this line: - error: No resource identifier found for attribute 'roundLayout' in package 'com.rarster.demowearman' - error: No resource identifier found for attribute 'rectLayout' in package 'com.rarster.demowearman'',

and then also gives an error in my main activity saying that R cannot be resolved to a variable, i am following this tutorial https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d. I have checked that i do have the roundlayout and rectlayout in my layout folder. Can anybody tell me what is going on and how to fix it? Thanks in advance

the code that the error is in is

    <?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub 
    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:id="@+id/watch_view_stub"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:rectLayout="@layout/rect"
    app:roundLayout="@layout/round"
    tools:context="com.rarster.demowearman.MainActivity"
    tools:deviceIds="wear" >

</android.support.wearable.view.WatchViewStub>
ilikeyoyo
  • 168
  • 4
  • 20

1 Answers1

2
  1. All xml attributes start with the lowercase letter.
  2. Neither app:rectLayout nor app:roundLayout should be placed in the manifest! They have to be used in layout file - in WatchViewStub parent view.

Like that:

<android.support.wearable.view.WatchViewStub
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/stub"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    app:rectLayout="@layout/rect"
    app:roundLayout="@layout/round"
    />

Your R cannot be resolved to a variable error is the effect of wrong resources files - they cannot be successfully compiled. So please fix the things above and all should be good.

Maciej Ciemięga
  • 10,125
  • 1
  • 41
  • 48
  • actually my bad i do have it in the watchview stub not the manifest, sorry for that and i have it as app:rectLayout and app:roundLayout and it still does not work. – ilikeyoyo Aug 20 '14 at 22:35
  • "it gives errors in the xml" - if you won't post the message of your errors no-one will be able to guess what is wrong in your code... Please ALWAYS post errors messages and post your code containing the errors. – Maciej Ciemięga Aug 21 '14 at 06:39
  • sorry i am a seventh grader and i don't always pay attention, i fixed that, and i put the code too – ilikeyoyo Aug 21 '14 at 22:46
  • You haven't posted the error message... How can anyone know what error do you have if you didn't write it?:\ – Maciej Ciemięga Aug 22 '14 at 08:45
  • it was in the title and it was in the text, but i guess i will make it clearer... – ilikeyoyo Aug 22 '14 at 14:07
  • My bad, haven't noticed that. But now it's a lot better visible:) This error means that you have something wrong with your wearable-support library. Please make sure that you have imported the wearable-support library project right + that it is referenced from your project. Make sure that all resources are in place in the `wearable-1.0.0` project. You should see for example `attrs.xml` file in `wearable-1.0.0/res/values/attrs.xml` <- this is place where xml attribures are stored (your error is about not being able to find these definitions). – Maciej Ciemięga Aug 22 '14 at 14:22
  • i have nothing in my values folder in wearable-1.0.0 Should i delete it and re-import it and add it as a dependency? – ilikeyoyo Aug 22 '14 at 22:32
  • i re imported it and added it as a dependency but that did not seem to work and i still have nothing in my values folder! – ilikeyoyo Aug 22 '14 at 23:32
  • Little correction: In wearable-1.0.0 lib all attrs are stored in `values/values.xml` file (and not as I previously said in `values/attrs.xml`, but it is just a different name - not important here). You said that you have nothing in `values` folder - so you have done something wrong. Please follow the tutorial once again and make sure that every step is done properly (inside the `wearable-1.0.0` there is a res folder with all resources - it need to be used when exporting it to eclipse. I have wrote about that in my answer here http://stackoverflow.com/a/24754539/3827276, you can also check it. – Maciej Ciemięga Aug 23 '14 at 07:05
  • actually i found the values.xml in side the values folder, what i did was i downloaded wearable 1.0.0 from github and then added as a dependency, now it is working! Thanks. – ilikeyoyo Aug 23 '14 at 15:07