Как заставить JeroMQ работать с Android Studio? - PullRequest
0 голосов
/ 05 ноября 2019

Мой процесс:

Установка IntelliJ

Создание нового проекта

Добавление JeroMQ с помощью файла> Структура проекта> Глобальные библиотеки> org.zeromq: jeromq: 0.5.1

Создайте следующие java-файлы в src:

publisher.java

import org.zeromq.ZMQ;
import org.zeromq.ZContext;
import org.zeromq.SocketType;
import java.util.concurrent.TimeUnit;

public class publisher {
    public static void main(String[] args) throws Exception
    {
        try (ZContext context = new ZContext()) {
            // Socket to talk to clients
            ZMQ.Socket socket = context.createSocket(SocketType.PUB);
            socket.bind("tcp://*:5559");
            System.out.println("starting loop");
            String message = "hello";
            while (!Thread.currentThread().isInterrupted()) {
                // Block until a message is received
                socket.send(message);

                // Print the message
                System.out.println(
                        "Sent: [" + message + "]"
                );
                TimeUnit.SECONDS.sleep(1);
            }
        }
    }
}

subscriber.java

import org.zeromq.ZMQ;
import org.zeromq.ZContext;
import org.zeromq.SocketType;

public class subscriber {
    public static void main(String[] args) throws Exception
    {
        try (ZContext context = new ZContext()) {
            // Socket to talk to clients
            ZMQ.Socket socket = context.createSocket(SocketType.SUB);
            socket.connect("tcp://127.0.0.1:5559");
            socket.subscribe("");
            System.out.println("starting loop");

            while (!Thread.currentThread().isInterrupted()) {
                // Block until a message is received
                String message = socket.recvStr(0);

                // Print the message
                System.out.println(
                        "Received: [" + message + "]"
                );
            }
        }
    }
}

Запустите publisher.java, затем подписчика.java (одновременно). Оба работают.

Загрузить Android Studio (моя версия - 3.5.2)

Создать новый проект (Basic Activity, API 28 / Android 9.0 просто для простоты).

Изменитьнастройки проекта: Файл> Структура проекта> Модули> (Компилировать SDK Версии 29, Инструменты сборки версии 29.0.2, Совместимость исходного кода 1.8, Целевая совместимость 1.8)

Добавить JeroMQ с помощью Build> Редактировать библиотеки и зависимости> Зависимости>app> org.zeromq: jeromq: 0.5.1

Добавьте следующий класс в app> java> (верхняя папка):

subscriber.java

package com.example.testttt;

import org.zeromq.ZMQ;
import org.zeromq.ZContext;
import org.zeromq.SocketType;

public class subscriber implements Runnable {

    @Override
    public void run()
    {
        try (ZContext context = new ZContext()) {
            // Socket to talk to clients
            ZMQ.Socket socket = context.createSocket(SocketType.SUB);
            socket.connect("tcp://10.0.2.2:5559");
            socket.subscribe("");
            System.out.println("starting loop");

            while (!Thread.currentThread().isInterrupted()) {
                // Block until a message is received
                String message = socket.recvStr(0);

                // Print the message
                System.out.println(
                        "Received: [" + message + "]"
                );
            }
        }
    }
}

(Примечание: использует 10.0.2.2 для подключения к localhost, как указано здесь (https://developer.android.com/studio/run/emulator-networking)).

Отредактируйте метод onCreate в файле MainActivity.java следующим образом:

package com.example.testttt;

import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
        new Thread(new subscriber()).start();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

Создать виртуальное устройство Android (Pixel 2 API 28, x86). Запустите его.

Нажмите «Отладка приложения», когда publisher.java все еще работает на ПК. Появляется первая напечатанная строка «цикл запуска», но другие сообщения не появляются. Послеминута или около того появляется следующая ошибка (это неПолный вывод, потому что тело этого поста ограничено):

A/example.testtt: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: field operation on NULL object: 0x0
    java_vm_ext.cc:542]     in call to GetIntField
    java_vm_ext.cc:542]     from void sun.nio.ch.FileDispatcherImpl.preClose0(java.io.FileDescriptor)
    java_vm_ext.cc:542] "FinalizerDaemon" daemon prio=5 tid=6 Runnable
    java_vm_ext.cc:542]   | group="system" sCount=0 dsCount=0 flags=0 obj=0x16400448 self=0xee1f8200
    java_vm_ext.cc:542]   | sysTid=4740 nice=4 cgrp=default sched=0/0 handle=0xd45a0970
    java_vm_ext.cc:542]   | state=R schedstat=( 720319 0 12 ) utm=0 stm=0 core=0 HZ=100
    java_vm_ext.cc:542]   | stack=0xd449d000-0xd449f000 stackSize=1042KB
    java_vm_ext.cc:542]   | held mutexes= "mutator lock"(shared held)
    java_vm_ext.cc:542]   native: #00 pc 004152f6  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+198)
    java_vm_ext.cc:542]   native: #01 pc 0051048e  /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+382)
    java_vm_ext.cc:542]   native: #02 pc 0050b743  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+83)
    java_vm_ext.cc:542]   native: #03 pc 0031a8b0  /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1088)
    java_vm_ext.cc:542]   native: #04 pc 0031ad21  /system/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, char*)+113)
A/example.testtt: java_vm_ext.cc:542]   native: #05 pc 000d60f7  /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+71)
    java_vm_ext.cc:542]   native: #06 pc 000dc5b3  /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckFieldAccess(art::ScopedObjectAccess&, _jobject*, _jfieldID*, bool, art::Primitive::Type)+323)
    java_vm_ext.cc:542]   native: #07 pc 000dbcc0  /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetField(char const*, _JNIEnv*, _jobject*, _jfieldID*, bool, art::Primitive::Type)+1056)
    java_vm_ext.cc:542]   native: #08 pc 000c5c84  /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetIntField(_JNIEnv*, _jobject*, _jfieldID*)+68)
    java_vm_ext.cc:542]   native: #09 pc 0001680d  /system/lib/libopenjdk.so (fdval+45)
    java_vm_ext.cc:542]   native: #10 pc 000179f9  /system/lib/libopenjdk.so (FileDispatcherImpl_preClose0+41)
    java_vm_ext.cc:542]   native: #11 pc 0011534a  /system/framework/x86/boot.oat (offset 114000) (java.lang.System.setErr0 [DEDUPED]+170)
    java_vm_ext.cc:542]   native: #12 pc 005f0d52  /system/lib/libart.so (art_quick_invoke_static_stub+418)
    java_vm_ext.cc:542]   native: #13 pc 000a30df  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+239)
    java_vm_ext.cc:542]   native: #14 pc 0029bca2  /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+338)
    java_vm_ext.cc:542]   native: #15 pc 00293e48  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1048)
    java_vm_ext.cc:542]   native: #16 pc 002d75be  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE0ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+158)
    java_vm_ext.cc:542]   native: #17 pc 002d1001  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73761)
    java_vm_ext.cc:542]   native: #18 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #19 pc 0012b5c8  /system/framework/boot.vdex (sun.nio.ch.DatagramDispatcher.preClose)
    java_vm_ext.cc:542]   native: #20 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #21 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #22 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #23 pc 002d44dd  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+669)
    java_vm_ext.cc:542]   native: #24 pc 002d10ad  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73933)
    java_vm_ext.cc:542]   native: #25 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #26 pc 0012f3b6  /system/framework/boot.vdex (sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel)
    java_vm_ext.cc:542]   native: #27 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #28 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #29 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #30 pc 002d44dd  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+669)
    java_vm_ext.cc:542]   native: #31 pc 002d10ad  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73933)
    java_vm_ext.cc:542]   native: #32 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #33 pc 000db5c2  /system/framework/boot.vdex (java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel)
    java_vm_ext.cc:542]   native: #34 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #35 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #36 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #37 pc 002d44dd  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+669)
    java_vm_ext.cc:542]   native: #38 pc 002d10ad  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73933)
    java_vm_ext.cc:542]   native: #39 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #40 pc 000db22a  /system/framework/boot.vdex (java.nio.channels.spi.AbstractInterruptibleChannel.close)
    java_vm_ext.cc:542]   native: #41 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #42 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #43 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
A/example.testtt: java_vm_ext.cc:542]   native: #44 pc 002d44dd  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+669)
    java_vm_ext.cc:542]   native: #45 pc 002d10ad  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73933)
    java_vm_ext.cc:542]   native: #46 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #47 pc 0012f398  /system/framework/boot.vdex (sun.nio.ch.SocketChannelImpl.finalize)
    java_vm_ext.cc:542]   native: #48 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #49 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #50 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #51 pc 002d44dd  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+669)
    java_vm_ext.cc:542]   native: #52 pc 002d10ad  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+73933)
    java_vm_ext.cc:542]   native: #53 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #54 pc 000aec02  /system/framework/boot-core-libart.vdex (java.lang.Daemons$FinalizerDaemon.doFinalize)
    java_vm_ext.cc:542]   native: #55 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #56 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #57 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #58 pc 002d5fce  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE1ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+286)
    java_vm_ext.cc:542]   native: #59 pc 002d184a  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+75882)
    java_vm_ext.cc:542]   native: #60 pc 005f7762  /system/lib/libart.so (ExecuteSwitchImplAsm+18)
    java_vm_ext.cc:542]   native: #61 pc 000aec5c  /system/framework/boot-core-libart.vdex (java.lang.Daemons$FinalizerDaemon.runInternal)
    java_vm_ext.cc:542]   native: #62 pc 002661c9  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+521)
    java_vm_ext.cc:542]   native: #63 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #64 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #65 pc 005bc493  /system/lib/libart.so (MterpInvokeVirtual+691)
    java_vm_ext.cc:542]   native: #66 pc 005e2d21  /system/lib/libart.so (ExecuteMterpImpl+14241)
    java_vm_ext.cc:542]   native: #67 pc 000aeaf8  /system/framework/boot-core-libart.vdex (java.lang.Daemons$Daemon.run+20)
    java_vm_ext.cc:542]   native: #68 pc 00266216  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598)
    java_vm_ext.cc:542]   native: #69 pc 0026c79c  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220)
    java_vm_ext.cc:542]   native: #70 pc 00293e2b  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019)
    java_vm_ext.cc:542]   native: #71 pc 005bd574  /system/lib/libart.so (MterpInvokeInterface+1444)
    java_vm_ext.cc:542]   native: #72 pc 005e2f21  /system/lib/libart.so (ExecuteMterpImpl+14753)
    java_vm_ext.cc:542]   native: #73 pc 000ca806  /system/framework/boot.vdex (java.lang.Thread.run+12)
    java_vm_ext.cc:542]   native: #74 pc 00266216  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598)
    java_vm_ext.cc:542]   native: #75 pc 0026c68e  /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+126)
    java_vm_ext.cc:542]   native: #76 pc 005a953d  /system/lib/libart.so (artQuickToInterpreterBridge+1277)
    java_vm_ext.cc:542]   native: #77 pc 005f6c6d  /system/lib/libart.so (art_quick_to_interpreter_bridge+77)
    java_vm_ext.cc:542]   native: #78 pc 005f6dff  /system/lib/libart.so (???)
    java_vm_ext.cc:542]   at sun.nio.ch.FileDispatcherImpl.preClose0(Native method)
    java_vm_ext.cc:542]   at sun.nio.ch.SocketDispatcher.preClose(SocketDispatcher.java:69)
    java_vm_ext.cc:542]   at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(SocketChannelImpl.java:885)
    java_vm_ext.cc:542]   - locked <0x07640989> (a java.lang.Object)
    java_vm_ext.cc:542]   at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:234)
    java_vm_ext.cc:542]   at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:116)
    java_vm_ext.cc:542]   - locked <0x0975fd8e> (a java.lang.Object)
    java_vm_ext.cc:542]   at sun.nio.ch.SocketChannelImpl.finalize(SocketChannelImpl.java:939)
    java_vm_ext.cc:542]   at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
    java_vm_ext.cc:542]   at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
    java_vm_ext.cc:542]   at java.lang.Daemons$Daemon.run(Daemons.java:103)
    java_vm_ext.cc:542]   at java.lang.Thread.run(Thread.java:764)
    java_vm_ext.cc:542] 
A/example.testtt: runtime.cc:558] Runtime aborting...
    runtime.cc:558] Dumping all threads without appropriate locks held: thread list lock mutator lock
    runtime.cc:558] All threads:
    runtime.cc:558] DALVIK THREADS (19):
    runtime.cc:558] "FinalizerDaemon" prio=5 tid=6 Runnable
    runtime.cc:558]   | group="" sCount=0 dsCount=0 flags=0 obj=0x16400448 self=0xee1f8200
    runtime.cc:558]   | sysTid=4740 nice=4 cgrp=default sched=0/0 handle=0xd45a0970
    runtime.cc:558]   | state=R schedstat=( 41366495 1328311 69 ) utm=2 stm=2 core=0 HZ=100
    runtime.cc:558]   | stack=0xd449d000-0xd449f000 stackSize=1042KB
    runtime.cc:558]   | held mutexes= "abort lock" "mutator lock"(shared held)
    runtime.cc:558]   native: #00 pc 004152f6  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+198)
    runtime.cc:558]   native: #01 pc 0051048e  /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+382)
    runtime.cc:558]   native: #02 pc 0050b743  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+83)
    runtime.cc:558]   native: #03 pc 0052e564  /system/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+916)
    runtime.cc:558]   native: #04 pc 00526286  /system/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+534)
    runtime.cc:558]   native: #05 pc 005254d4  /system/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+1316)
    runtime.cc:558]   native: #06 pc 004efdcc  /system/lib/libart.so (art::AbortState::DumpAllThreads(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, art::Thread*) const+284)
    runtime.cc:558]   native: #07 pc 004dc52f  /system/lib/libart.so (art::Runtime::Abort(char const*)+287)
    runtime.cc:558]   native: #08 pc 005cd833  /system/lib/libart.so (_ZNSt3__110__function6__funcIPFvPKcENS_9allocatorIS5_EES4_EclEOS3_+35)
    runtime.cc:558]   native: #09 pc 00007ccc  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+828)
    runtime.cc:558]   native: #10 pc 0031ab5f  /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1775)
    runtime.cc:558]   native: #11 pc 0031ad21  /system/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, char*)+113)
    runtime.cc:558]   native: #12 pc 000d60f7  /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+71)
    runtime.cc:558]   native: #13 pc 000dc5b3  /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckFieldAccess(art::ScopedObjectAccess&, _jobject*, _jfieldID*, bool, art::Primitive::Type)+323)
    runtime.cc:558]   native: #14 pc 000dbcc0  /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetField(char const*, _JNIEnv*, _jobject*, _jfieldID*, bool, art::Primitive::Type)+1056)
    runtime.cc:558]   native: #15 pc 000c5c84  /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetIntField(_JNIEnv*, _jobject*, _jfieldID*)+68)
    runtime.cc:558]   native: #16 pc 0001680d  /system/lib/libopenjdk.so (fdval+45)
    runtime.cc:558]   native: #17 pc 000179f9  /system/lib/libopenjdk.so (FileDispatcherImpl_preClose0+41)
    runtime.cc:558]   at sun.nio.ch.FileDispatcherImpl.preClose0(Native method)
    runtime.cc:558]   at sun.nio.ch.SocketDispatcher.preClose(SocketDispatcher.java:69)
    runtime.cc:558]   at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(SocketChannelImpl.java:885)
    runtime.cc:558]   - locked <0x07640989> (a java.lang.Object)
    runtime.cc:558]   at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:234)
    runtime.cc:558]   at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:116)
    runtime.cc:558]   - locked <0x0975fd8e> (a java.lang.Object)
A/example.testtt: runtime.cc:558]   at sun.nio.ch.SocketChannelImpl.finalize(SocketChannelImpl.java:939)
    runtime.cc:558]   at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
    runtime.cc:558]   at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
    runtime.cc:558]   at java.lang.Daemons$Daemon.run(Daemons.java:103)
    runtime.cc:558]   at java.lang.Thread.run(Thread.java:764)
    runtime.cc:558] 
    runtime.cc:558] "main" prio=5 tid=1 Native
    runtime.cc:558]   | group="" sCount=1 dsCount=0 flags=1 obj=0x756c6ee0 self=0xee1f4000
    runtime.cc:558]   | sysTid=4694 nice=-10 cgrp=default sched=0/0 handle=0xf2dbb494
    runtime.cc:558]   | state=S schedstat=( 916061562 62246943 365 ) utm=72 stm=19 core=3 HZ=100
    runtime.cc:558]   | stack=0xff6bc000-0xff6be000 stackSize=8MB
    runtime.cc:558]   | held mutexes=
    runtime.cc:558]   kernel: ep_poll+0x28e/0x33f
    runtime.cc:558]   kernel: SyS_epoll_wait+0x96/0xb4
    runtime.cc:558]   kernel: SyS_epoll_pwait+0x93/0x114
    runtime.cc:558]   kernel: do_fast_syscall_32+0xd5/0x148
    runtime.cc:558]   kernel: sysenter_flags_fixed+0x8/0x12

Любая подсказка, что я делаю неправильно?

...