启动新活动时的Android java.lang.NoClassDefFoundError

时间:2012-05-17 22:25:50

标签: android

当我尝试启动新活动时,我收到了java.lang.NoClassDefFoundError。以下是我的AndroidManifest.xml:

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

    <uses-sdk android:minSdkVersion="15" />
  <uses-permission android:name="android.permission.INTERNET" />

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

            <activity
                android:name=".LoginActivity"
                android:label="Login to your Account">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".RegisterActivity"
            android:label="Register New Account">
        </activity>

        <activity
            android:name=".GoogleMapsActivity"
            android:label="Google Maps">
        </activity>

        <uses-library android:name="com.google.android.maps"/>

    </application>

</manifest>

GoogleMapsActivity.java代码

package com.practice.googlemaps;

import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class GoogleMapsActivity extends MapActivity {

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    MapView mapView = (MapView)findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
  }

    @Override
    protected boolean isRouteDisplayed() {
      // TODO Auto-generated method stub
      return false;
    }
}

以下是我用来启动新活动的一行:

Intent i = new Intent(getApplicationContext(), GoogleMapsActivity.class);
startActivity(i);

我已检查过我的课程GoogleMapsActivity.java,文件存在且拼写/措辞全部匹配。

我怀疑错误可能是由我的AndroidManifest.xml引起的,但我找不到问题。

有人可以指出我正确的方向吗?

2 个答案:

答案 0 :(得分:3)

确保<uses-library android:name="com.google.android.maps"/>是正确的位置。

答案 1 :(得分:1)

你肯定错过了添加一个jar文件以便Noclassdeffound错误     将会呈现。如果你已经添加了所有jar文件,即使这个错误来了,那么我给你一个绝对有效的最佳答案。只需在你的项目中创建libs文件夹,并在libs文件夹中添加所有jar文件,你的问题肯定会解决。

相关问题