我在尝试创建启动服务的新意图时遇到了NoClassDefFounderror。我已经检查了一些建议的解决方案,比如在/libs路径中包含库,我相信我已经正确地设置了这些解决方案。我已经包括我的清单和来源在下面。任何帮助都将不胜感激。
下面是我在eclipse中的文件结构的屏幕截图
这是我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ajinex.easysave"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="11" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".CouponsActivity"
        android:screenOrientation="portrait"
        android:launchMode="singleInstance"
        android:label="@string/title_activity_coupons" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
        <!--  service  -->
        <service android:enabled="true" android:name=".LocationCheckService" >
    </service>
</application>

这是我在main活动中的呼叫代码:
Intent LocationCheck = new Intent(this, LocationCheckService.class);
    this.startService(LocationCheck);

这是我的locationcheckservice.class
public class LocationCheckService extends Service {
    public class LocalBinder extends Binder {
        LocationCheckService getService() {
            return LocationCheckService.this;
        }
    }


    public final IBinder mBinder = new LocalBinder();

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if(checkNetworkRechability()){
            Toast.makeText(this, "EasySave Service Started", Toast.LENGTH_LONG).show();
            getSysLocation();
        }
        return START_STICKY;
    }
    @Override
    public void onCreate() {

    }

    @Override
    public void onDestroy() {

    }
}

以下是与此问题相关的一些logcat输出:
07-16 00:09:36.712: I/AndroidRuntime(312): NOTE: attach of thread 'Binder Thread #3' failed
07-16 00:09:37.702: W/ActivityManager(59): Unable to start service Intent { act=com.ajinex.easysave.location.LocationCheckService }: not found
07-16 00:09:38.162: I/ActivityManager(59): Displayed activity   com.ajinex.easysave/.MainActivity: 1568 ms (total 1568 ms)

最佳答案

根据错误消息(com.ajinu.easysave.location.locationcheckservice)和包名称(com.ajinu.easysave),您需要在清单文件中将服务声明为.location.locationcheckservice。

10-07 17:17