Сбой приложения при отправке сообщений из основного потока пользовательского интерфейса в другой поток - PullRequest
0 голосов
/ 22 февраля 2020

Я пытаюсь отправить сообщение из моего onCreate() метода MainActivity в поток Connection, который затем отправляет данные на сервер через udp socket. Но приложение постоянно падает. Подскажите, пожалуйста, как отправить данные из потока пользовательского интерфейса в не-пользовательский поток.

Метод onCreate () MainActivity.

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Looper.prepare();
        this.connection = new Thread(new Connection());
        this.connection.start();
        Message msg = Message.obtain();
        Bundle bundle = new Bundle();
        bundle.putString("NAVIGATION", "Message");
        msg.setData(bundle);
        if(Connection.getHandler() == null){
            Connection.getHandler().sendMessage(msg);
        }
        Looper.loop();
    }

Класс соединения

public class Connection implements Runnable {

    private DatagramSocket client_socket = null;
    private InetAddress host = null;
    private byte[] buffer = null;
    private static Handler handler = null;
    private String data = null;

    @Override
    public void run() {
        boolean status = this.create();
        if(status) {
            while (true) {
                Looper.prepare();
                Connection.handler = new Handler(){
                    @Override
                    public void handleMessage(Message msg) {
                        super.handleMessage(msg);
                        Connection.handler.obtainMessage();
                        String data = msg.getData().getString("NAVIGATION");
                        send(data);
                    }
                };
                Looper.loop();
            }
        }
    }
    private boolean create(){
        try{
            this.client_socket = new DatagramSocket();
        } catch(Exception e){
            Log.e("Connection", e.getMessage());
            return false;
        }
        try{
            this.host = InetAddress.getByName("192.168.0.107");
        } catch (Exception e){
            Log.e("Connection", e.getMessage());
            return false;
        }
        return true;
    }

    private void send(String nav){
        this.buffer = nav.getBytes();

        DatagramPacket packet = new DatagramPacket(buffer, buffer.length, this.host, 12345);

        try{
            this.client_socket.send(packet);
        } catch (Exception e){
            Log.e("Connection", e.getMessage());
        }
    }

    public static Handler getHandler() {
        return Connection.handler;
    }
}

logcat

I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method androidx.appcompat.app.AppCompatDelegateImpl.mapNightMode
W/dalvikvm: VFY: unable to resolve virtual method 410: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
I/dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method androidx.appcompat.view.WindowCallbackWrapper.onPointerCaptureChanged
W/dalvikvm: VFY: unable to resolve interface method 2169: Landroid/view/Window$Callback;.onPointerCaptureChanged (Z)V
I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method androidx.appcompat.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
W/dalvikvm: VFY: unable to resolve interface method 2171: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
    VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method androidx.appcompat.view.WindowCallbackWrapper.onSearchRequested
W/dalvikvm: VFY: unable to resolve interface method 2173: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method androidx.appcompat.view.WindowCallbackWrapper.onWindowStartingActionMode
W/dalvikvm: VFY: unable to resolve interface method 2177: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method androidx.appcompat.widget.TintTypedArray.getChangingConfigurations
W/dalvikvm: VFY: unable to resolve virtual method 610: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method androidx.appcompat.widget.TintTypedArray.getType
W/dalvikvm: VFY: unable to resolve virtual method 632: Landroid/content/res/TypedArray;.getType (I)I
I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method androidx.core.content.ContextCompat.createDeviceProtectedStorageContext
W/dalvikvm: VFY: unable to resolve virtual method 381: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method androidx.core.content.ContextCompat.getCodeCacheDir
W/dalvikvm: VFY: unable to resolve virtual method 388: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File;
I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method androidx.core.content.ContextCompat.getColor
W/dalvikvm: VFY: unable to resolve virtual method 389: Landroid/content/Context;.getColor (I)I
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method androidx.core.content.ContextCompat.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 390: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method androidx.core.content.ContextCompat.getDataDir
W/dalvikvm: VFY: unable to resolve virtual method 392: Landroid/content/Context;.getDataDir ()Ljava/io/File;
I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method androidx.core.content.ContextCompat.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 393: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;
I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method androidx.core.content.ContextCompat.getNoBackupFilesDir
W/dalvikvm: VFY: unable to resolve virtual method 401: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;
I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method androidx.core.content.ContextCompat.getSystemService
W/dalvikvm: VFY: unable to resolve virtual method 410: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
I/dalvikvm: Could not find method android.content.Context.getSystemServiceName, referenced from method androidx.core.content.ContextCompat.getSystemServiceName
W/dalvikvm: VFY: unable to resolve virtual method 412: Landroid/content/Context;.getSystemServiceName (Ljava/lang/Class;)Ljava/lang/String;
I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method androidx.core.content.ContextCompat.isDeviceProtectedStorage
W/dalvikvm: VFY: unable to resolve virtual method 415: Landroid/content/Context;.isDeviceProtectedStorage ()Z
I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method androidx.core.content.ContextCompat.startForegroundService
W/dalvikvm: VFY: unable to resolve virtual method 430: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName;
I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method androidx.appcompat.widget.ActionBarContainer.startActionModeForChild
W/dalvikvm: VFY: unable to resolve virtual method 2678: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
    VFY: unable to find class referenced in signature (Landroid/graphics/Outline;)
I/dalvikvm: Could not find method android.graphics.drawable.Drawable.getOutline, referenced from method androidx.appcompat.widget.ActionBarBackgroundDrawable.getOutline
W/dalvikvm: VFY: unable to resolve virtual method 935: Landroid/graphics/drawable/Drawable;.getOutline (Landroid/graphics/Outline;)V
I/dalvikvm: Could not find method android.graphics.drawable.Drawable.getOutline, referenced from method androidx.appcompat.widget.ActionBarBackgroundDrawable.getOutline
W/dalvikvm: VFY: unable to resolve virtual method 935: Landroid/graphics/drawable/Drawable;.getOutline (Landroid/graphics/Outline;)V
I/dalvikvm: Could not find method android.view.View.addKeyboardNavigationClusters, referenced from method androidx.core.view.ViewCompat.addKeyboardNavigationClusters
W/dalvikvm: VFY: unable to resolve virtual method 1742: Landroid/view/View;.addKeyboardNavigationClusters (Ljava/util/Collection;I)V
I/dalvikvm: Failed resolving Landroidx/core/view/ViewCompat$OnUnhandledKeyEventListenerWrapper; interface 407 'Landroid/view/View$OnUnhandledKeyEventListener;'
W/dalvikvm: Link of class 'Landroidx/core/view/ViewCompat$OnUnhandledKeyEventListenerWrapper;' failed
E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper', referenced from method androidx.core.view.ViewCompat.addOnUnhandledKeyEventListener
W/dalvikvm: VFY: unable to resolve new-instance 1397 (Landroidx/core/view/ViewCompat$OnUnhandledKeyEventListenerWrapper;) in Landroidx/core/view/ViewCompat;
I/dalvikvm: Could not find method android.view.View.cancelDragAndDrop, referenced from method androidx.core.view.ViewCompat.cancelDragAndDrop
W/dalvikvm: VFY: unable to resolve virtual method 1750: Landroid/view/View;.cancelDragAndDrop ()V
E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.dispatchApplyWindowInsets
W/dalvikvm: VFY: unable to resolve check-cast 425 (Landroid/view/WindowInsets;) in Landroidx/core/view/ViewCompat;
I/dalvikvm: Could not find method android.view.View.dispatchNestedFling, referenced from method androidx.core.view.ViewCompat.dispatchNestedFling
W/dalvikvm: VFY: unable to resolve virtual method 1758: Landroid/view/View;.dispatchNestedFling (FFZ)Z
I/dalvikvm: Could not find method android.view.View.dispatchNestedPreFling, referenced from method androidx.core.view.ViewCompat.dispatchNestedPreFling
W/dalvikvm: VFY: unable to resolve virtual method 1759: Landroid/view/View;.dispatchNestedPreFling (FF)Z
I/dalvikvm: Could not find method android.view.View.dispatchNestedPreScroll, referenced from method androidx.core.view.ViewCompat.dispatchNestedPreScroll
W/dalvikvm: VFY: unable to resolve virtual method 1760: Landroid/view/View;.dispatchNestedPreScroll (II[I[I)Z
I/dalvikvm: Could not find method android.view.View.dispatchNestedScroll, referenced from method androidx.core.view.ViewCompat.dispatchNestedScroll
W/dalvikvm: VFY: unable to resolve virtual method 1761: Landroid/view/View;.dispatchNestedScroll (IIII[I)Z
I/dalvikvm: Could not find method android.view.View.getBackgroundTintList, referenced from method androidx.core.view.ViewCompat.getBackgroundTintList
W/dalvikvm: VFY: unable to resolve virtual method 1776: Landroid/view/View;.getBackgroundTintList ()Landroid/content/res/ColorStateList;
I/dalvikvm: Could not find method android.view.View.getBackgroundTintMode, referenced from method androidx.core.view.ViewCompat.getBackgroundTintMode
W/dalvikvm: VFY: unable to resolve virtual method 1777: Landroid/view/View;.getBackgroundTintMode ()Landroid/graphics/PorterDuff$Mode;
I/dalvikvm: Could not find method android.view.View.getElevation, referenced from method androidx.core.view.ViewCompat.getElevation
W/dalvikvm: VFY: unable to resolve virtual method 1785: Landroid/view/View;.getElevation ()F
I/dalvikvm: Could not find method android.view.View.getImportantForAutofill, referenced from method androidx.core.view.ViewCompat.getImportantForAutofill
W/dalvikvm: VFY: unable to resolve virtual method 1792: Landroid/view/View;.getImportantForAutofill ()I
I/dalvikvm: Could not find method android.view.View.getNextClusterForwardId, referenced from method androidx.core.view.ViewCompat.getNextClusterForwardId
W/dalvikvm: VFY: unable to resolve virtual method 1810: Landroid/view/View;.getNextClusterForwardId ()I
I/dalvikvm: Could not find method android.view.View.getScrollIndicators, referenced from method androidx.core.view.ViewCompat.getScrollIndicators
W/dalvikvm: VFY: unable to resolve virtual method 1829: Landroid/view/View;.getScrollIndicators ()I
I/dalvikvm: Could not find method android.view.View.getTransitionName, referenced from method androidx.core.view.ViewCompat.getTransitionName
W/dalvikvm: VFY: unable to resolve virtual method 1835: Landroid/view/View;.getTransitionName ()Ljava/lang/String;
I/dalvikvm: Could not find method android.view.View.getTranslationZ, referenced from method androidx.core.view.ViewCompat.getTranslationZ
W/dalvikvm: VFY: unable to resolve virtual method 1838: Landroid/view/View;.getTranslationZ ()F
I/dalvikvm: Could not find method android.view.View.getZ, referenced from method androidx.core.view.ViewCompat.getZ
W/dalvikvm: VFY: unable to resolve virtual method 1848: Landroid/view/View;.getZ ()F
I/dalvikvm: Could not find method android.view.View.hasExplicitFocusable, referenced from method androidx.core.view.ViewCompat.hasExplicitFocusable
W/dalvikvm: VFY: unable to resolve virtual method 1849: Landroid/view/View;.hasExplicitFocusable ()Z
I/dalvikvm: Could not find method android.view.View.hasNestedScrollingParent, referenced from method androidx.core.view.ViewCompat.hasNestedScrollingParent
W/dalvikvm: VFY: unable to resolve virtual method 1852: Landroid/view/View;.hasNestedScrollingParent ()Z
I/dalvikvm: Could not find method android.view.View.isFocusedByDefault, referenced from method androidx.core.view.ViewCompat.isFocusedByDefault
W/dalvikvm: VFY: unable to resolve virtual method 1861: Landroid/view/View;.isFocusedByDefault ()Z
I/dalvikvm: Could not find method android.view.View.isImportantForAutofill, referenced from method androidx.core.view.ViewCompat.isImportantForAutofill
W/dalvikvm: VFY: unable to resolve virtual method 1863: Landroid/view/View;.isImportantForAutofill ()Z
I/dalvikvm: Could not find method android.view.View.isKeyboardNavigationCluster, referenced from method androidx.core.view.ViewCompat.isKeyboardNavigationCluster
W/dalvikvm: VFY: unable to resolve virtual method 1866: Landroid/view/View;.isKeyboardNavigationCluster ()Z
I/dalvikvm: Could not find method android.view.View.isNestedScrollingEnabled, referenced from method androidx.core.view.ViewCompat.isNestedScrollingEnabled
W/dalvikvm: VFY: unable to resolve virtual method 1871: Landroid/view/View;.isNestedScrollingEnabled ()Z
I/dalvikvm: Could not find method android.view.View.keyboardNavigationClusterSearch, referenced from method androidx.core.view.ViewCompat.keyboardNavigationClusterSearch
W/dalvikvm: VFY: unable to resolve virtual method 1877: Landroid/view/View;.keyboardNavigationClusterSearch (Landroid/view/View;I)Landroid/view/View;
E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.onApplyWindowInsets
W/dalvikvm: VFY: unable to resolve check-cast 425 (Landroid/view/WindowInsets;) in Landroidx/core/view/ViewCompat;
E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method androidx.core.view.ViewCompat.removeOnUnhandledKeyEventListener
W/dalvikvm: VFY: unable to resolve check-cast 407 (Landroid/view/View$OnUnhandledKeyEventListener;) in Landroidx/core/view/ViewCompat;
I/dalvikvm: Could not find method android.view.View.requestApplyInsets, referenced from method androidx.core.view.ViewCompat.requestApplyInsets
W/dalvikvm: VFY: unable to resolve virtual method 1903: Landroid/view/View;.requestApplyInsets ()V
I/dalvikvm: Could not find method android.view.View.requireViewById, referenced from method androidx.core.view.ViewCompat.requireViewById
W/dalvikvm: VFY: unable to resolve virtual method 1909: Landroid/view/View;.requireViewById (I)Landroid/view/View;
I/dalvikvm: Could not find method android.view.View.restoreDefaultFocus, referenced from method androidx.core.view.ViewCompat.restoreDefaultFocus
W/dalvikvm: VFY: unable to resolve virtual method 1911: Landroid/view/View;.restoreDefaultFocus ()Z
I/dalvikvm: Could not find method android.view.View.setAutofillHints, referenced from method androidx.core.view.ViewCompat.setAutofillHints
W/dalvikvm: VFY: unable to resolve virtual method 1919: Landroid/view/View;.setAutofillHints ([Ljava/lang/String;)V
I/dalvikvm: Could not find method android.view.View.setBackgroundTintList, referenced from method androidx.core.view.ViewCompat.setBackgroundTintList
W/dalvikvm: VFY: unable to resolve virtual method 1923: Landroid/view/View;.setBackgroundTintList (Landroid/content/res/ColorStateList;)V
I/dalvikvm: Could not find method android.view.View.setBackgroundTintMode, referenced from method androidx.core.view.ViewCompat.setBackgroundTintMode
W/dalvikvm: VFY: unable to resolve virtual method 1924: Landroid/view/View;.setBackgroundTintMode (Landroid/graphics/PorterDuff$Mode;)V
I/dalvikvm: Could not find method android.view.View.setElevation, referenced from method androidx.core.view.ViewCompat.setElevation
W/dalvikvm: VFY: unable to resolve virtual method 1926: Landroid/view/View;.setElevation (F)V
I/dalvikvm: Could not find method android.view.View.setFocusedByDefault, referenced from method androidx.core.view.ViewCompat.setFocusedByDefault
W/dalvikvm: VFY: unable to resolve virtual method 1929: Landroid/view/View;.setFocusedByDefault (Z)V
I/dalvikvm: Could not find method android.view.View.setImportantForAutofill, referenced from method androidx.core.view.ViewCompat.setImportantForAutofill
W/dalvikvm: VFY: unable to resolve virtual method 1933: Landroid/view/View;.setImportantForAutofill (I)V
I/dalvikvm: Could not find method android.view.View.setKeyboardNavigationCluster, referenced from method androidx.core.view.ViewCompat.setKeyboardNavigationCluster
W/dalvikvm: VFY: unable to resolve virtual method 1934: Landroid/view/View;.setKeyboardNavigationCluster (Z)V
I/dalvikvm: Could not find method android.view.View.setNestedScrollingEnabled, referenced from method androidx.core.view.ViewCompat.setNestedScrollingEnabled
W/dalvikvm: VFY: unable to resolve virtual method 1943: Landroid/view/View;.setNestedScrollingEnabled (Z)V
I/dalvikvm: Could not find method android.view.View.setNextClusterForwardId, referenced from method androidx.core.view.ViewCompat.setNextClusterForwardId
W/dalvikvm: VFY: unable to resolve virtual method 1944: Landroid/view/View;.setNextClusterForwardId (I)V
I/dalvikvm: Could not find method android.view.View.setOnApplyWindowInsetsListener, referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
W/dalvikvm: VFY: unable to resolve virtual method 1945: Landroid/view/View;.setOnApplyWindowInsetsListener (Landroid/view/View$OnApplyWindowInsetsListener;)V
I/dalvikvm: Failed resolving Landroidx/core/view/ViewCompat$1; interface 397 'Landroid/view/View$OnApplyWindowInsetsListener;'
W/dalvikvm: Link of class 'Landroidx/core/view/ViewCompat$1;' failed
E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$1', referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
W/dalvikvm: VFY: unable to resolve new-instance 1391 (Landroidx/core/view/ViewCompat$1;) in Landroidx/core/view/ViewCompat;
I/dalvikvm: Could not find method android.view.View.setPointerIcon, referenced from method androidx.core.view.ViewCompat.setPointerIcon
W/dalvikvm: VFY: unable to resolve virtual method 1956: Landroid/view/View;.setPointerIcon (Landroid/view/PointerIcon;)V
I/dalvikvm: Could not find method android.view.View.setScrollIndicators, referenced from method androidx.core.view.ViewCompat.setScrollIndicators
W/dalvikvm: VFY: unable to resolve virtual method 1964: Landroid/view/View;.setScrollIndicators (I)V
I/dalvikvm: Could not find method android.view.View.setScrollIndicators, referenced from method androidx.core.view.ViewCompat.setScrollIndicators
W/dalvikvm: VFY: unable to resolve virtual method 1965: Landroid/view/View;.setScrollIndicators (II)V
I/dalvikvm: Could not find method android.view.View.setTooltipText, referenced from method androidx.core.view.ViewCompat.setTooltipText
W/dalvikvm: VFY: unable to resolve virtual method 1969: Landroid/view/View;.setTooltipText (Ljava/lang/CharSequence;)V
I/dalvikvm: Could not find method android.view.View.setTransitionName, referenced from method androidx.core.view.ViewCompat.setTransitionName
W/dalvikvm: VFY: unable to resolve virtual method 1970: Landroid/view/View;.setTransitionName (Ljava/lang/String;)V
I/dalvikvm: Could not find method android.view.View.setTranslationZ, referenced from method androidx.core.view.ViewCompat.setTranslationZ
W/dalvikvm: VFY: unable to resolve virtual method 1973: Landroid/view/View;.setTranslationZ (F)V
I/dalvikvm: Could not find method android.view.View.setZ, referenced from method androidx.core.view.ViewCompat.setZ
W/dalvikvm: VFY: unable to resolve virtual method 1977: Landroid/view/View;.setZ (F)V
I/dalvikvm: Could not find method android.view.View.startDragAndDrop, referenced from method androidx.core.view.ViewCompat.startDragAndDrop
W/dalvikvm: VFY: unable to resolve virtual method 1980: Landroid/view/View;.startDragAndDrop (Landroid/content/ClipData;Landroid/view/View$DragShadowBuilder;Ljava/lang/Object;I)Z
I/dalvikvm: Could not find method android.view.View.startNestedScroll, referenced from method androidx.core.view.ViewCompat.startNestedScroll
W/dalvikvm: VFY: unable to resolve virtual method 1981: Landroid/view/View;.startNestedScroll (I)Z
I/dalvikvm: Could not find method android.view.View.stopNestedScroll, referenced from method androidx.core.view.ViewCompat.stopNestedScroll
W/dalvikvm: VFY: unable to resolve virtual method 1982: Landroid/view/View;.stopNestedScroll ()V
I/dalvikvm: Could not find method android.view.View.updateDragShadow, referenced from method androidx.core.view.ViewCompat.updateDragShadow
W/dalvikvm: VFY: unable to resolve virtual method 1983: Landroid/view/View;.updateDragShadow (Landroid/view/View$DragShadowBuilder;)V
I/dalvikvm: Failed resolving Landroidx/core/view/ViewCompat$OnUnhandledKeyEventListenerWrapper; interface 407 'Landroid/view/View$OnUnhandledKeyEventListener;'
W/dalvikvm: Link of class 'Landroidx/core/view/ViewCompat$OnUnhandledKeyEventListenerWrapper;' failed
I/dalvikvm: Failed resolving Landroidx/core/view/ViewCompat$1; interface 397 'Landroid/view/View$OnApplyWindowInsetsListener;'
W/dalvikvm: Link of class 'Landroidx/core/view/ViewCompat$1;' failed
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method androidx.appcompat.content.res.AppCompatResources.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 390: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method androidx.appcompat.widget.ResourcesWrapper.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 573: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method androidx.appcompat.widget.ResourcesWrapper.getDrawableForDensity
W/dalvikvm: VFY: unable to resolve virtual method 575: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method androidx.appcompat.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 187 (Landroid/graphics/drawable/RippleDrawable;) in Landroidx/appcompat/widget/AppCompatImageHelper;
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method androidx.appcompat.widget.AppCompatTextView.getAutoSizeMaxTextSize
W/dalvikvm: VFY: unable to resolve virtual method 2993: Landroid/widget/TextView;.getAutoSizeMaxTextSize ()I
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method androidx.appcompat.widget.AppCompatTextView.getAutoSizeMinTextSize
W/dalvikvm: VFY: unable to resolve virtual method 2994: Landroid/widget/TextView;.getAutoSizeMinTextSize ()I
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method androidx.appcompat.widget.AppCompatTextView.getAutoSizeStepGranularity
W/dalvikvm: VFY: unable to resolve virtual method 2995: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method androidx.appcompat.widget.AppCompatTextView.getAutoSizeTextAvailableSizes
W/dalvikvm: VFY: unable to resolve virtual method 2996: Landroid/widget/TextView;.getAutoSizeTextAvailableSizes ()[I
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method androidx.appcompat.widget.AppCompatTextView.getAutoSizeTextType
W/dalvikvm: VFY: unable to resolve virtual method 2997: Landroid/widget/TextView;.getAutoSizeTextType ()I
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method androidx.appcompat.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration
W/dalvikvm: VFY: unable to resolve virtual method 3052: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithConfiguration (IIII)V
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method androidx.appcompat.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes
W/dalvikvm: VFY: unable to resolve virtual method 3053: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithPresetSizes ([II)V
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method androidx.appcompat.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults
W/dalvikvm: VFY: unable to resolve virtual method 3054: Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults (I)V
I/dalvikvm: Could not find method android.widget.TextView.setFirstBaselineToTopHeight, referenced from method androidx.appcompat.widget.AppCompatTextView.setFirstBaselineToTopHeight
W/dalvikvm: VFY: unable to resolve virtual method 3066: Landroid/widget/TextView;.setFirstBaselineToTopHeight (I)V
I/dalvikvm: Could not find method android.widget.TextView.setLastBaselineToBottomHeight, referenced from method androidx.appcompat.widget.AppCompatTextView.setLastBaselineToBottomHeight
W/dalvikvm: VFY: unable to resolve virtual method 3072: Landroid/widget/TextView;.setLastBaselineToBottomHeight (I)V
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method androidx.appcompat.widget.AppCompatTextHelper.loadFromAttributes
W/dalvikvm: VFY: unable to resolve virtual method 2995: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
I/dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method androidx.appcompat.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring
W/dalvikvm: VFY: unable to resolve static method 1386: Landroid/text/StaticLayout$Builder;.obtain (Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder;
I/dalvikvm: Could not find method android.graphics.Color.getModel, referenced from method androidx.core.graphics.ColorUtils.compositeColors
W/dalvikvm: VFY: unable to resolve virtual method 738: Landroid/graphics/Color;.getModel ()Landroid/graphics/ColorSpace$Model;
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x415adc80)

1 Ответ

0 голосов
/ 22 февраля 2020
 if(Connection.getHandler() == null){
     Connection.getHandler().sendMessage(msg);
  }

Похоже, это виновник - вы говорите "если оно пустое, используйте его"

возможно, вы хотели написать Connection.getHandler() != null

Также, пожалуйста, помещайте сообщения журнала в onCreate и в вашей инициализации соединения, чтобы убедиться, что соединение создано до запуска onCreate

Другое дело: у вас есть Thread connection = new Thread(new Connection()); в качестве локальной переменной. попробуйте сделать его членом, потому что, как только он выходит из области видимости, он удаляется из памяти.

...