启动新的Activity android时NoClassDefFoundError(未知来源)

时间:2014-10-25 15:56:28

标签: android noclassdeffounderror

我正在尝试开展一项活动。这是我的代码:

btnShowOnMap.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent i = new Intent(getApplicationContext(),
                    PlacesMapActivity.class);
            // Sending user current geo location
            i.putExtra("user_latitude", Double.toString(gps.getLatitude()));
            i.putExtra("user_longitude", Double.toString(gps.getLongitude()));

            // passing near places to map activity
            i.putExtra("near_places", nearPlaces);
            // staring activity
            startActivity(i);
        }
    });

Manifest xml文件如下所示:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhive.googleplacesandmaps"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <!--  Add Google Map Library -->
    <uses-library android:name="com.google.android.maps" />



    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- SinglePlaceActivity -->
    <activity android:name=".SinglePlaceActivity" android:label="Place Details">
    </activity>

    <!-- PlacesMapActivity -->
    <activity android:name=".PlacesMapActivity" android:label="Near Places Map View">
    </activity>

</application>

<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Access Location -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

它编译没有问题,但是当我想创建一个新的intent时,我在线程“main”java.lang.NoClassDefFoundError:com / androidhive / googleplacesandmaps / PlacesMapActivity Error中得到一个Exception。有人知道可能导致问题的原因吗?

1 个答案:

答案 0 :(得分:0)

这是一个链接问题。如果您使用eclipse,请确保将正确的jar文件添加到项目中。另外,请确保正确定义类路径