我正在尝试建立一个java服务器和一个通过Tor进行通信的Android客户端。使用this页面指令,我已经设法使用Java客户端。但是,当我尝试将客户端代码用于Android项目时,应用程序崩溃了。我的android-client代码在下面。
MainActivity.java
public class MainActivity extends Activity {
private BootStrapper bootstrapper;
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bootstrapper = new BootStrapper();
bootstrapper.execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private class BootStrapper extends AsyncTask<Object, Object, Object> {
@Override
protected Object doInBackground(Object... params) {
TcpipNetAddress remoteAddress = new TcpipNetAddress("localhost", 3000);
NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TCPIP);
netLayer.waitUntilReady();
try {
NetSocket netSocket = netLayer.createNetSocket(null, null, remoteAddress);
} catch (IOException e) {
e.printStackTrace();
}
return null;}
}
}
我在服务器端没有错误,但在客户端这是logCat的输出
06-07 22:07:26.981: W/dalvikvm(2364): VFY: unable to resolve new-instance 2065 (Lorg/silvertunnel_ng/netlib/api/util/TcpipNetAddress;) in Lcom/example/hellotor/MainActivity$BootStrapper;