1

I'm trying to write dashclock extension, so I started with the example-extension but I can't get it work properly. I can see this example extension in dashclock settings in extensions list but it is not on the actual dashclock widget. It crashes in backgound periodically with this stack trace:

02-22 17:04:31.118: E/AndroidRuntime(25888): FATAL EXCEPTION: main
02-22 17:04:31.118: E/AndroidRuntime(25888): java.lang.RuntimeException: Unable to instantiate service com.example.dashclock.exampleextension.ExampleExtension: java.lang.ClassNotFoundException: Didn't find class "com.example.dashclock.exampleextension.ExampleExtension" on path: /data/app/com.example.dashclock.exampleextension-1.apk
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2513)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.app.ActivityThread.access$1600(ActivityThread.java:141)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.os.Looper.loop(Looper.java:137)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.app.ActivityThread.main(ActivityThread.java:5041)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at java.lang.reflect.Method.invokeNative(Native Method)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at java.lang.reflect.Method.invoke(Method.java:511)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at dalvik.system.NativeStart.main(Native Method)
02-22 17:04:31.118: E/AndroidRuntime(25888): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.dashclock.exampleextension.ExampleExtension" on path: /data/app/com.example.dashclock.exampleextension-1.apk
02-22 17:04:31.118: E/AndroidRuntime(25888):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-22 17:04:31.118: E/AndroidRuntime(25888):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2510)
02-22 17:04:31.118: E/AndroidRuntime(25888):    ... 10 more

thanks for help

Charles
  • 50,943
  • 13
  • 104
  • 142
Semanticer
  • 1,962
  • 1
  • 18
  • 29

2 Answers2

2

The error:

java.lang.ClassNotFoundException: Didn't find class "com.example.dashclock.exampleextension.ExampleExtension" on path: /data/app/com.example.dashclock.exampleextension-1.apk

This means that it cannot locate ExampleExtension.java which should be located in the com.example.dash clock.exampleextension package


First off, do not import the example files into eclipse, start a brand new Android Application

Deselect the create Activity button when it asks

After it is created, right click on the src folder and add a package. Then right click the package and create a new class. This new class will be your extension. Get the 2 jar files from Dashclock site here

Drag them into your libs folder

Add this to your manifest

    <application android:label="@string/app_name"
    android:icon="@drawable/ic_extension_yourIcon"
    android:theme="@android:style/Theme.Holo">

    <service android:name=".YourExtension"
        android:icon="@drawable/ic_extension_your_icon"
        android:label="@string/your_extension_title"
        android:permission="com.google.android.apps.dashclock.permission.READ_EXTENSION_DATA">
        <intent-filter>
            <action android:name="com.google.android.apps.dashclock.Extension" />
        </intent-filter>
        <meta-data android:name="protocolVersion" android:value="1" />
        <meta-data android:name="description"
            android:value="@string/your_extension_description" />
    </service>

</application>

Save the Manifest, find the errors indicated by red lines and add the appropriate strings to your strings.xml

Here is an empty Extension class

    public class YourExtension extends DashClockExtension {

    @Override
    protected void onUpdateData(int reason) {

    publishUpdate(new ExtensionData()
    .visible(true)
    .icon(R.drawable.ic_extension_yourIcon)
    .status("This is the text when minimized")
    .expandedTitle("This is the white Title text when expanded")
    .expandedBody("This is the grey footer text when expanded")
    .clickIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))));

    }
    }
Kev
  • 118,037
  • 53
  • 300
  • 385
jb15613
  • 359
  • 4
  • 12
  • After following @jb15613, I get my extension to compile and show up in the extensions list. I'm getting `03-07 14:57:00.566: E/AndroidRuntime(14508): FATAL EXCEPTION: main` `03-07 14:57:00.566: E/AndroidRuntime(14508): java.lang.NoClassDefFoundError: com.google.android.apps.dashclock.api.ExtensionData` I've imported the api.jar and am getting no compilation errors in Eclipse. The class (ExtensionData) *is* there but cannot be seen. – alexismorin Mar 07 '13 at 14:01
  • There are to different Jar files on the site, you should import them both. What is the Class ExtensionData? In my extension, i have only one class, which is declared in the manifest – jb15613 Mar 07 '13 at 23:58
  • I am having the same problem. I am using Android studio. I have followed you guide but I still get the class not found error. – CeejeeB May 18 '13 at 13:45
0

In case it's not working after doing what jb15613 explained very well (I saw in comments people - like me - for whom it wasn't working), on IntelliJ, set in the module dependencies tab in project structure that you want it to provide the JAR as "Compile".

tiwiz
  • 327
  • 5
  • 19