czchlong
czchlong

Reputation: 2574

Android java.lang.NoClassDefFoundError when launching new activity

I am getting a java.lang.NoClassDefFoundError when I try to launch my new activity. Below is my 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>

Code for 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;
    }
}

And the following is the line I'm using to launch the new activity:

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

I have checked my class GoogleMapsActivity.java, the file is present and the spelling/wording all match.

I suspect the error may be caused by my AndroidManifest.xml, but I cannot find the problem.

Could someone please point me in the right direction?

Upvotes: 1

Views: 2977

Answers (2)

itechDroid
itechDroid

Reputation: 1031

you are definitely missing to add one jar file so that the Noclassdeffound error will show. and if u have add all jar file even then this error comes then i give you one best answer that definitely works. just create libs folder in ur project and add all jar file in libs folder and your problem definitely solves out.

Upvotes: 1

Tugrul
Tugrul

Reputation: 1808

Be sure that the <uses-library android:name="com.google.android.maps"/> is right location .

Upvotes: 3

Related Questions