Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecifying Android project dependencies (in Eclipse)
    text
    copied!<p>I have two Android projects, a 'library project' containing a custom layout, and an 'application project' containing an application which uses the layout.</p> <p>Everything seems to build and execute fine, except that the visual layout editor throws a ClassNotFoundException (which I assume is a bug in the plug-in), but when I try to start to make use of the attributes I defined for the custom layout in the xml, I can no longer build. That is; this works:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;se.fnord.android.layout.PredicateLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="asdfasdf" /&gt; &lt;/se.fnord.android.layout.PredicateLayout&gt; </code></pre> <p>Whereas this does not:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;se.fnord.android.layout.PredicateLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fnord="http://schemas.android.com/apk/res/se.fnord.android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView fnord:layout_horizontalSpacing="1px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="asdfasdf" /&gt; &lt;/se.fnord.android.layout.PredicateLayout&gt; </code></pre> <p>The build fails with a message from aapt:</p> <blockquote> <p>ERROR No resource identifier found for attribute 'layout_horizontalSpacing' in package 'se.fnord.android'</p> </blockquote> <p>The resource identifier does exist in the R-file and attrs.xml contained the library project, and if I put the layout code and resources directly in the application project everything works fine. The layout_horizontalSpacing attribute (and layout_verticalSpacing) is a custom attribute used in the PredicateLayout.LayoutParam class to specify the distance to the next widget.</p> <p>So far I've tried the standard eclipse ways by specifying project references and build path project dependencies. I was also told to try the tag in the application manifest, which did not help.</p> <p>So, what do I need to do for the references in the xml-file to work?</p> <p>I don't know if it's relevant, but the 'library' manifest looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="se.fnord.android" android:versionCode="1" android:versionName="1.0.0"&gt; &lt;/manifest&gt; </code></pre> <p>The 'application' manifest like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="se.fnord.appname" android:versionCode="1" android:versionName="1.0.0"&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".AppName" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>(The 'PredicateLayout', btw, is a cleaned-up version of <a href="https://stackoverflow.com/questions/549451">this</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload