5

I am currently trying to add a widget to my application and have been basing my implementation on this code http://developer.android.com/resources/samples/StackWidget/index.html

I have put all my stack widget related classes in their own package within my main package.Package setyp

When I try to add the widget it is unable to bind and hence the cards are not displayed (it just states the default text "This is the empty view")

Below is my manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bencallis.dealpad" android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/ic_launcher"
        android:logo="@drawable/logo" android:theme="@style/DealPadTheme"
        android:hardwareAccelerated="true" android:uiOptions="splitActionBarWhenNarrow">
        <activity android:label="@string/app_name" android:name=".DealPadActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SettingsActivity" />
        <activity android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />


        <!-- Widgets -->
        <receiver android:name=".stackwidget.StackWidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/stackwidgetinfo" />
        </receiver>

        <service android:name="stackwidget.StackWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS"
            android:exported="false" />


    </application>

</manifest>

Error message:

E/RemoteViewsAdapterServiceConnection(474): bind(): Unknown component ComponentInfo{com.bencallis.dealpad/com.bencallis.dealpad.stackwidget.StackWidgetService}

I am sure there is a simple mistake somewhere which is making the component info repeat com.bencallis.dealpad.

Any ideas?

bencallis
  • 3,478
  • 4
  • 32
  • 58
  • It seems if I don't put it in it's own package I can get it to work. Surely there must be an easy way to get it to work in it's own package? – bencallis Feb 15 '12 at 12:52
  • I have a similar issue: My WidgetProvider class is in another package and I always get the **Unknown component** error. Funny thing is, I have another Widget that isn't a collection widget, and it works just fine on another package. – Henrique de Sousa Apr 23 '13 at 09:25

1 Answers1

4

It turned out it was to do with my manifest and a problem locating the service. I was missing a . in the name (which gives it the path).

Silly mistake!

bencallis
  • 3,478
  • 4
  • 32
  • 58
  • I personally try to put components in a path other than the application package path. Then I fully qualify the class name. It's much easier to avoid Eclipse refactor bugs. – Jeremy Edwards Feb 20 '12 at 05:58