找不到类异常?

时间:2015-10-31 12:12:07

标签: android

enter image description here

package com.mnt.samplem; 公共类Locatem extends FragmentActivity实现了LocationListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //show error dialog if GoolglePlayServices not available
    if (!isGooglePlayServicesAvailable()) {
        finish();
    }
    setContentView(R.layout.mapl);
    SupportMapFragment supportMapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.googleMap);
    googleMap = supportMapFragment.getMap();

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String bestProvider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(bestProvider);
    if (location != null) {
        onLocationChanged(location);
    }
    locationManager.requestLocationUpdates(bestProvider, 2000, 0, this);
     slatitude = location.getLatitude();
     slongitude = location.getLongitude();

}

即使我在清单文件中添加了库,它仍然在运行状态下显示NoClassDefFoundError异常。

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

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

      <uses-library android:required="true" android:name="com.google.android.maps" />
    <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="com.mnt.samplem.DistanceTravelled"></activity>
    <activity android:name="com.mnt.samplem.Locatem"></activity>
      <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyDcSgi40I7XW2ug4VTQKrO2W1hzQNZGCiU" />


</application>

mainactivity

公共类MainActivity扩展了SherlockActivity {

Button btn_submit;
private ActionBar actionBar;
RelativeLayout menuLayout;
PopupWindow pwindo;
ImageView btnmenu;
TextView txthome,txtmenu;

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // this.setTheme(R.style.Theme_Sherlock_Light_DarkActionBar);
        setTheme(R.style.Sherlock___Theme_Light);

    } else {
        setTheme(R.style.Theme_Sherlock_Light_DarkActionBar);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    actionBar = getActionBar();
    getActionBar().setDisplayHomeAsUpEnabled(true);
    actionBar.setCustomView(R.layout.actionbar);
    actionBar
            .setDisplayOptions(com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_CUSTOM);
    menuLayout = (RelativeLayout) actionBar.getCustomView().findViewById(
            R.id.menu_layout);
    btnmenu = (ImageView) findViewById(R.id.menu_bttn);
    LayoutInflater inflater = (LayoutInflater) MainActivity.this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.fraglayout,
            (ViewGroup) findViewById(R.id.layadd));
    pwindo = new PopupWindow(layout, 300, LayoutParams.WRAP_CONTENT, true);

    pwindo.setContentView(layout);
    txthome = (TextView) layout.findViewById(R.id.tl);
    txtmenu = (TextView) layout.findViewById(R.id.dc);


    btnmenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            // button2.setVisibility(View.VISIBLE);
            // button1.setVisibility(View.GONE);
            pwindo.setBackgroundDrawable(new ColorDrawable(
                    android.R.color.transparent));
            pwindo.setOutsideTouchable(true);
            pwindo.setFocusable(true);
            pwindo.getBackground().setAlpha(0);
            Log.d("HomeActivity", "HomeActivity" + pwindo);
            pwindo.showAsDropDown(btnmenu, 0, 0);

        }
    });
    txthome.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pwindo.dismiss();
            Intent intent = new Intent(
                    MainActivity.this,
                    Locatem.class);
            startActivity(intent);

        }
    });

    txtmenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pwindo.dismiss();
            Intent intent = new Intent(
                    MainActivity.this,
                    DistanceTravelled.class);
            startActivity(intent);

        }
    });

}

}

0 个答案:

没有答案