带有新eclipse包的NoClassDefFoundError

时间:2012-12-03 23:02:45

标签: android noclassdeffounderror

客户告知我他们收到错误。在他们提交的报告中,它继续提出NoClassDefFoundError。看来我的其他客户都没有遇到这个问题。我在摩托罗拉Droid Maxx上运行应用程序时遇到此问题。客户在一个有根的Droid Bionic上运行应用程序。在我的2.3版本上一切正常,但当我将其更新为2.4时,出现了这个问题。我还用新的替换了我的计算机,现在我正在运行Windows 8并安装了adt包。我在将> -90更改为> -85时对该文件所做的唯一更改。下面是代码......我还在代码下面包含了错误报告。这只发生在手机上。

    import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;


public class ConnectivityCheck extends Activity {

    TelephonyManager        Tel;
   MyPhoneStateListener    MyListener;
   boolean isGsm;
   boolean cellAvailable;
int strengthAmplitudeGSM;
int strengthAmplitudeCDMA;


@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);         

    ConnectivityManager connec =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

    if (connec.getNetworkInfo(0) != null)
    {
        cellAvailable = true;
    }

    if (cellAvailable)
    {
    /* Update the listener, and start it */
        MyListener   = new MyPhoneStateListener();
        Tel = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE);
        Tel.listen(MyListener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    }

 if (connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED)
     {
        startActivity(new Intent(ConnectivityCheck.this, LicenseCheck.class));
        if (cellAvailable)
        {
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
        }
        finish();
     }
  else if (cellAvailable)
  {
     if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED && strengthAmplitudeCDMA >= -90)
     {
         startActivity(new Intent(ConnectivityCheck.this, LicenseCheck.class));
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
        finish();
     }
     else if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED && isGsm && strengthAmplitudeGSM >= 10 && strengthAmplitudeGSM <= 31)
     {
        startActivity(new Intent(ConnectivityCheck.this, LicenseCheck.class));
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE); 
        finish();
     }
     else 
    {

        startActivity(new Intent(ConnectivityCheck.this, ProtocolsMMenuActivity.class));
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE); 
        finish();
     }
  }
  else
  {
        startActivity(new Intent(ConnectivityCheck.this, ProtocolsMMenuActivity.class));  
        if (cellAvailable)
        {
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
        }
    finish();
  }

}

/* Called when the application is minimized */
    @Override
   protected void onPause()
    {
      super.onPause();
            if (cellAvailable)
        {
        Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
        }
   }

    /* Called when the application resumes */
   @Override
   protected void onResume()
   {
      super.onResume();
        if (cellAvailable)
        {
        Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
        }
       }


   /* Start the PhoneState listener */
    private class MyPhoneStateListener extends PhoneStateListener
    {
      /* Get the Signal strength from the provider, each tiome there is an update */
      @Override
      public void onSignalStrengthsChanged(SignalStrength signalStrength)
      {


    isGsm = signalStrength.isGsm();
    strengthAmplitudeGSM = signalStrength.getGsmSignalStrength();
    strengthAmplitudeCDMA = signalStrength.getCdmaDbm();

     super.onSignalStrengthsChanged(signalStrength);
 }
};/* End of private Class */
}

以下是错误报告

    java.lang.NoClassDefFoundError: com.emsprotocols.njalsprotocolspaidac.ConnectivityCheck
at com.emsprotocols.njalsprotocolspaidac.ProtocolsSplashActivity$1.onAnimationEnd        (ProtocolsSplashActivity.java:144)
 at android.view.animation.AnimationSet.getTransformation(AnimationSet.java:411)
 at android.view.animation.Animation.getTransformation(Animation.java:920)
 at android.view.ViewGroup.drawChild(ViewGroup.java:2657)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
 at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
 at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
 at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
 at android.view.View.draw(View.java:11009)
 at android.widget.FrameLayout.draw(FrameLayout.java:450)
 at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2154)
 at android.view.ViewRootImpl.draw(ViewRootImpl.java:2096)
 at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1679)
 at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2558)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:137)
 at android.app.ActivityThread.main(ActivityThread.java:4722)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:511)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
 at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

这是SDK工具的r21版本的常见问题。进入项目设置,然后进入Java Build Path。如果你展开“Android Dependencies”,你会发现你的libs文件夹中有一些.jars现在有重复。

从顶层删除所有重复项,只留下Android Dependencies文件夹中的重复项。然后清理你的项目,你应该再次去。