Я пытаюсь использовать пакет snmp4j и создать класс с именем TestSnmp.
Возникла исключительная ситуация NoClassDefFoundError во время вызова функции CommunityTarget () из пакета snmp4j.
Я не знаю почему, похоже, внутренняя ошибка в функции 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)