在CommunityTarget()函数(snmp4j)上引发NoClassDefFoundError

时间:2019-05-31 14:37:01

标签: java android noclassdeffounderror snmp4j

我尝试使用软件包snmp4j并创建一个名为TestSnmp的类。

在从snmp4j包调用功能CommunityTarget()的过程中,我引发了异常NoClassDefFoundError。 我不知道为什么,这在AbstractTarget函数中似乎是内部错误。该代码有什么问题?感谢您的帮助。

implementation 'org.snmp4j:snmp4j:2.6.3'

class TestSnmp {
    private CommunityTarget target;

    TestSnmp(String ipAddress) {
        try {
            target = new CommunityTarget();
            target.setCommunity(new OctetString("public"));
            target.setAddress(GenericAddress.parse("udp:" + ipAddress + "/161"));
            target.setRetries(2);
            target.setTimeout(1000);
            target.setVersion(SnmpConstants.version1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

这是完整的堆栈:

java.lang.RuntimeException: 
  at android.os.AsyncTask$3.done (AsyncTask.java:318)
  at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:354)
  at java.util.concurrent.FutureTask.setException (FutureTask.java:223)
  at java.util.concurrent.FutureTask.run (FutureTask.java:242)
  at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:243)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
  at java.lang.Thread.run (Thread.java:762)
Caused by: java.lang.NoClassDefFoundError: 
  at org.snmp4j.AbstractTarget.<init> (AbstractTarget.java)
  at org.snmp4j.CommunityTarget.<init> (CommunityTarget.java)
  at xxx.TestSnmp.<init> (TestSnmp.java)
  at xxx.TestIp.doInBackground (TestIp.java)
  at xxx.TestIp.doInBackground (TestIp.java)
  at android.os.AsyncTask$2.call (AsyncTask.java:304)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:243)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
  at java.lang.Thread.run (Thread.java:762)
Caused by: java.lang.ClassNotFoundException: 
  at java.lang.VMClassLoader.findLoadedClass (VMClassLoader.java)
  at java.lang.ClassLoader.findLoadedClass (ClassLoader.java:742)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:362)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at org.snmp4j.AbstractTarget.<init> (AbstractTarget.java)
  at org.snmp4j.CommunityTarget.<init> (CommunityTarget.java)
  at xxx.TestSnmp.<init> (TestSnmp.java)
  at xxx.TestIp.doInBackground (TestIp.java)
  at xxx.TestIp.doInBackground (TestIp.java)
  at android.os.AsyncTask$2.call (AsyncTask.java:304)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:243)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
  at java.lang.Thread.run (Thread.java:762)

0 个答案:

没有答案