1

我想使用(“/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)
4

1 回答 1

1

问题出在 apache-commons 库中。我使用的是 1.8(最新版本),但是对于这个 ttorrent 客户端,需要1.2 版本

client.setMaxDownloadRate(0.0);
0.0 对下载速度没有限制。但是下载速度很低,Android uTorrent 有更多。

于 2013-10-04T09:26:56.193 回答