我想创建一个可以使用我的Android设备捕获数据包流量的应用程序。我使用Jpcap库,但LogCat会输出以下错误:
java.lang.NoClassDefFoundError:jpcap.JpcapCaptor
我的代码是:
import jpcap.JpcapCaptor;
import jpcap.NetworkInterface;
import jpcap.NetworkInterfaceAddress;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity
{
private TextView net_devise;
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
}
public void informations( View v )
{
NetworkInterface[] device = JpcapCaptor.getDeviceList();
net_devise = ( TextView )findViewById( R.id.textview );
int i = 0;
for ( NetworkInterface d : device )
{
net_devise.setText( i++ + "\n" + "Description: " + d.description + "\n" + "d.datalink_description" + "\n" + d.datalink_name );
}
}
}