bittorrent客户端:ttorrent不起作用

时间:2013-10-03 13:52:53

标签: java android bittorrent

我想在(“/sdcard/file.torrent”)上使用已保存的.torrent文件开始简单下载。 我尝试过 ttorrent ,因为它是最简单的bittorrent客户端。
ttorrent on github.com 所以我尝试了这段代码,但有错误......

String filePath = "/sdcard/file.torrent";
String downPath = "/sdcard/A";                  

Client client = new Client (
    InetAddress.getLocalHost(),
    SharedTorrent.fromFile(
    new File(filePath),
    new File(downPath)
    )
);

client.setMaxDownloadRate(0.0);
client.setMaxUploadRate(0.0);           
client.download();
client.share(0);         
client.waitForCompletion();

日志:

E/AndroidRuntime(5992): FATAL EXCEPTION: main
E/AndroidRuntime(5992): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHex
E/AndroidRuntime(5992):     at com.turn.ttorrent.common.Torrent.byteArrayToHexString(Torrent.java:415)
E/AndroidRuntime(5992):     at com.turn.ttorrent.common.Torrent.<init>(Torrent.java:145)
E/AndroidRuntime(5992):     at com.turn.ttorrent.client.SharedTorrent.<init>(SharedTorrent.java:175)
E/AndroidRuntime(5992):     at com.turn.ttorrent.client.SharedTorrent.<init>(SharedTorrent.java:159)
E/AndroidRuntime(5992):     at com.turn.ttorrent.client.SharedTorrent.fromFile(SharedTorrent.java:239)
E/AndroidRuntime(5992):     at com.torrentsearch.activities.ResultList.onContextItemSelected(ResultList.java:435)
E/AndroidRuntime(5992):     at android.app.Activity.onMenuItemSelected(Activity.java:2647)
E/AndroidRuntime(5992):     at com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3921)
E/AndroidRuntime(5992):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
E/AndroidRuntime(5992):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
E/AndroidRuntime(5992):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
E/AndroidRuntime(5992):     at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:193)
E/AndroidRuntime(5992):     at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:934)
E/AndroidRuntime(5992):     at android.widget.AdapterView.performItemClick(AdapterView.java:301)
E/AndroidRuntime(5992):     at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
E/AndroidRuntime(5992):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:3071)
E/AndroidRuntime(5992):     at android.widget.AbsListView$1.run(AbsListView.java:3973)
E/AndroidRuntime(5992):     at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(5992):     at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(5992):     at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(5992):     at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(5992):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5992):     at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(5992):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
E/AndroidRuntime(5992):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
E/AndroidRuntime(5992):     at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

问题出现在apache-commons lib中。我使用了1.8(最新版本),但是需要这个ttorrent客户端1.2 version

client.setMaxDownloadRate(0.0);
0.0设置下载速度无限制。但下载速度很低,Android uTorrent还有更多。