Reputation: 606
I am using Jelly Bean v16 API, follow the Guide here: Developing an Accessibility Service
I haven't start to add anything, just a blank service, but it crash instantly after I try to start the service.
here is the code, which part I did wrong?
AndroidManifest.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.firstapp.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service android:name=".MyAccessibilityService" >
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>
MyAccessibilityService.java
:
package com.example.android.apis.accessibility;
import android.accessibilityservice.AccessibilityService;
import android.view.accessibility.AccessibilityEvent;
public class MyAccessibilityService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
}
@Override
public void onInterrupt() {
}
}
this is the error message of LogCat (and there are more).
07-17 18:38:28.660: E/AndroidRuntime(3334): FATAL EXCEPTION: main
07-17 18:38:28.660: E/AndroidRuntime(3334): java.lang.RuntimeException: Unable to instantiate service com.firstapp.service.MyAccessibilityService: java.lang.ClassNotFoundException: com.firstapp.service.MyAccessibilityService
07-17 18:38:28.660: E/AndroidRuntime(3334): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2347)
Upvotes: 0
Views: 330
Reputation: 1195
Your manifest is declaring the service to live within the Java package com.firstapp.service
, whereas the actual class is implemented in the com.example.android.apis.accessibility
package.
Change the package name in the MyAccessibilityService.java
file to: com.firstapp.service
Upvotes: 1