0

This is the error I get:

05-08 12:50:56.976: E/AndroidRuntime(1018): java.lang.NoClassDefFoundError:
nl.h.energy.android.userinterface.FragmentEnergyUsage

I used breakpoints and I have determined that the error is on this line

1   bar.addTab(bar.newTab()
2     .setText("energy usage")
3     .setTabListener( 
4     new nl.h.energy.android.helper.TabListener
5      <nl.h.energy.android.userinterface.FragmentEnergyUsage>
6       (this,"energyUsage",  
7        nl.h.energy.android.userinterface.FragmentEnergyUsage.class)));

The error occurs on line 6/7 I hope I have provide enough info. These classe are classes that I have written my self so, no problems with me having to import these classes or that these classes are missing in Android

the TabListener looks like this: http://developer.android.com/reference/android/app/ActionBar.html#newTab()

and the FragementEnergyUsage class looks like this:

package nl.h.energy.android..userinterface;

import nl.h.energy.userinterface.R;
import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class FragmentEnergyUsage extends Fragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("Test", "hello");
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.energy_usage, container, false);
        return view;
    }

    public void setText(String item) {
        TextView view = (TextView) getView().findViewById(R.id.detailsText);
        view.setText(item);
    }
}
mariomario
  • 660
  • 1
  • 9
  • 29
  • I've gotten NoClassDefFoundErrors in the past and it has usually been related to problems with Eclipse or a bad build or after upgrading my ADT plugins, etc. First line of troubleshooting might be to restart Eclipse and do a Project > Clean. Are these classes coming from a library project by any chance? – Rich May 08 '12 at 13:34
  • @Rich Um nope, thes classes aren't external but I will try your suggestion. – mariomario May 08 '12 at 13:39
  • 1
    your answer is here http://stackoverflow.com/questions/9857539/noclassdeffounderror-when-googleanalyticstracker-getinstance/9857669#9857669 – Akram May 08 '12 at 14:01
  • @Akki All my external jars are already in my lib folder, even before this error. – mariomario May 08 '12 at 14:09
  • @mariomario not in lib folder. put jar files in libs folder – MAC May 08 '12 at 14:26
  • @mariomario the folder name should be libs not lib. – Akram May 08 '12 at 14:34

2 Answers2

1

see this answer

also check whether you have registered all activity classes in your manifest file ?

Community
  • 1
  • 1
MAC
  • 15,799
  • 8
  • 54
  • 95
0

I got the

 java.lang.NoClassDefFoundError: com.android.example.SupportFragment
    at com.android.example.SupportFragmentActivity.onCreate()

on

SupportFragment extends SherlockFragment implements PopupMenu.OnMenuItemClickListener
...
    @Override
    public boolean onMenuItemClick(android.view.MenuItem item) {
        return onOptionsItemSelected(item);
    }

when trying to make a api 17 app compatible with api 8, the only indication was the logcat error above, so check that all your imported classes are supported if you get this error.

TouchBoarder
  • 6,422
  • 2
  • 52
  • 60