Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError Android Project [duplicate]

First of all, I know there are plenty of questions/answers about this topic, I've read most of them but still getting the error:

05-17 02:57:06.522: E/AndroidRuntime(17073): java.lang.NoClassDefFoundError: ar.com.package.android.MainActivity

The project worked just fine until I updated Eclipse from 21 to 22.

I have tried everything I could: I checked the manifest; Cleaned the project; checked my build path, tried the app in different android version, set java compliance level to 1.6 (libraries too), etc. I just can't figure out what the problem is.

Here's my manifest, I couldn't find anything wrong with it:

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

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/> 

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

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<permission
    android:name="ar.com.package.android.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="ar.com.package.android.permission.MAPS_RECEIVE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock.Light.DarkActionBar" 
    android:hardwareAccelerated="true">


    <meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key"/>


    <activity
        android:name="ar.com.package.android.SplashScreen"
        android:label="@string/app_name"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Black.NoTitleBar"
        android:windowSoftInputMode="stateHidden"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="ar.com.package.android.MainActivity"
        android:logo="@drawable/logo"
        android:screenOrientation="portrait" 
        android:windowSoftInputMode="stateHidden"
         >
    </activity>

    <activity
        android:name="ar.com.package.android.SearchForm"
        android:label="@string/title_activity_search_form"
        android:parentActivityName="ar.com.package.android.MainActivity"
        >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="ar.com.package.android.MainActivity" />
    </activity>

</application>

</manifest>

Any help is welcome. I'll keep researching, if I get the answer I'll post it.

EDIT

Here's the MainActivity code:

package ar.com.package.android;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;
import com.actionbarsherlock.view.*;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnCloseListener;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;

@SuppressLint("NewApi")
public class MainActivity extends SlidingFragmentActivity {

private SlidingMenu menu;
private Toast toast;
private long lastBackPressTime = 0;
private GoogleMap map;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // slidemenu
    setBehindContentView(R.layout.menu);

    setSlidingActionBarEnabled(false);

    menu = getSlidingMenu();
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffset(100);
    menu.setFadeDegree(0.35f);
    menu.setSlidingEnabled(false);

    menu.setOnCloseListener(new OnCloseListener() {
        @Override
        public void onClose() {
            menu.setSlidingEnabled(false);
        }
    });

    menu.setOnOpenListener(new OnOpenListener() {
        @Override
        public void onOpen() {
            menu.setSlidingEnabled(true);
        }
    });

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    // ---slide menu

    map = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil
            .isGooglePlayServicesAvailable(getBaseContext());

    if (status != ConnectionResult.SUCCESS) {

        Toast.makeText(this, "Google Maps no esta disponible.",
                Toast.LENGTH_LONG).show();

    } else {


        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
                -26.8175915814614, -65.22274105834958), 13));

        // Enabling MyLocation Layer of Google Map
        map.setMyLocationEnabled(true);
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getSupportMenuInflater().inflate(R.menu.main, menu);
    return true;
}

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        toggle();
        return true;

    case R.id.action_search:
        final int RESULT = 1;
        startActivityForResult(new Intent(MainActivity.this,
                SearchForm.class), RESULT);
        return true;

    case R.id.action_lineas:
        showDialogLineas();
        return true;

    case R.id.action_acercade:
        showDialogAcercaDe();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && !menu.isMenuShowing()) {

        if (this.lastBackPressTime < System.currentTimeMillis() - 4000) {
            toast = Toast.makeText(this,
                    "Presione Atrás nuevamente para cerrar",
                    Toast.LENGTH_LONG);
            toast.show();
            this.lastBackPressTime = System.currentTimeMillis();
        } else {
            if (toast != null) {
                toast.cancel();
            }
            super.onBackPressed();
        }

        return true;
    }
    return super.onKeyDown(keyCode, event);
}

public void onResultadosClicked(View view) {
    showMenu();
}

public void showDialogLineas(){
    DialogFragment dialog = new LineasDialog();
    dialog.show(getSupportFragmentManager(), "Lineas");
}

public void showDialogAcercaDe(){
    DialogFragment dialog = new AcercaDeDialog();
    dialog.show(getSupportFragmentManager(), "Acerca");
}
}
like image 876
VorteXavier Avatar asked May 17 '13 06:05

VorteXavier


1 Answers

Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.

like image 161
Krauxe Avatar answered Oct 16 '22 10:10

Krauxe