0

一位客户通知我,他们收到了错误消息。在他们提交的报告中,不断出现 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)
4

1 回答 1

1

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

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

于 2012-12-03T23:25:51.217 回答