我正在嘗試使用ttorrent庫爲android創建torrent應用程序。 我有一些問題。ttorrent庫HttpResponseMessage錯誤
05-29 23:07:23.388:E/AndroidRuntime(3681):致命異常:BT-宣佈(.. 393337)
05-29 23:07:23.388:E/AndroidRuntime( 3681):java.lang.NullPointerException
05-29 23:07:23.388:E/AndroidRuntime(3681):at com.turn.ttorrent.common.protocol.http.HTTPAnnounceResponseMessage.parse(HTTPAnnounceResponseMessage.java:105 )
05-29 23:07:23.388:E/AndroidRuntime(3681):at com.turn.ttorrent.common.protocol.http.HTTPTrackerMessage.parse(HTTPTrackerMessage.java:51)
05-29 23:07:23.388:E/AndroidRuntime(3681):在com.turn.ttorrent.client.announce.HTTPTrackerClient.announce(HTTPTrackerClient.java:124)
05-29 23: 07/23.388:E/AndroidRuntime(3681):at com.turn.ttorrent.client.announce.Announce.run(Announce.java:224)
05-29 23:07:23.388:E/AndroidRuntime(3681) ):在java.lang.Thread.run(Thread.java:856)
public static HTTPAnnounceResponseMessage parse(ByteBuffer data)
throws IOException, MessageValidationException {
BEValue decoded = BDecoder.bdecode(data);
if (decoded == null) {
throw new MessageValidationException(
"Could not decode tracker message (not B-encoded?)!");
}
Map<String, BEValue> params = decoded.getMap();
try {
List<Peer> peers;
try {
// First attempt to decode a compact response, since we asked
// for it.
peers = toPeerList(params.get("peers").getBytes());
} catch (InvalidBEncodingException ibee) {
// Fall back to peer list, non-compact response, in case the
// tracker did not support compact responses.
peers = toPeerList(params.get("peers").getList());
}
return new HTTPAnnounceResponseMessage(data,
params.get("interval").getInt(),
params.get("complete").getInt(),
params.get("incomplete").getInt(),
peers);
} catch (InvalidBEncodingException ibee) {
throw new MessageValidationException("Invalid response " +
"from tracker!", ibee);
} catch (UnknownHostException uhe) {
throw new MessageValidationException("Invalid peer " +
"in tracker response!", uhe);
}
沒有鍵,例如「INTERV al「或」complete「或」inclomplete「是params。有兩個鍵「同級」和「最小間隔」。
據我調用客戶端方法下載後,它從跟蹤器請求一些信息,然後嘗試解析這些信息。這就是錯誤所在。
所以,問題是爲什麼這樣呢?在圖書館裏是錯誤還是我有什麼問題?
那麼,究竟你「從ttorrent例如開始」。 因爲在我下載了文件之後,我在Eclipse中創建了一個新項目。然後我將所有文件複製粘貼到我的src目錄。 然後下載了所有的jar包,比如簡單的框架,commons.io等等。 我可以在TrackerService類中看到錯誤。 response.setText(「Not Found」); 給出錯誤。 Resoponse根本就沒有這種方法。 – user1685095