当我在没有调试器

时间:2016-10-03 08:02:06

标签: android google-maps debugging

从昨天起,我的应用程序在没有调试器的情况下启动时挂起。当我调试应用程序一切正常。我不知道是否应该发布我认为过多的代码。 我使用的是Google Maps API。

logcat的(错误):

  

10-03 09:53:12.172 666-680 /? E / Sensors:poll()失败(中断   系统调用)10-03 09:53:15.802 666-680 /? E / Sensors:poll()失败   (系统中断呼叫)10-03 09:53:17.128   18439-18520 / com.example.luick.boat_rc E / dalvikvm:致命   spin-on-suspend,dumping threads 10-03 09:53:17.250   18439-18520 / com.example.luick.boat_rc E / dalvikvm:threadid = 31:卡住了   在threadid = 11,放弃10-03 09:53:17.566 666-687 /? E / ANRManager:   ANR在com.example.luick.boat_rc中   (com.example.luick.boat_rc / .MainActivity)                                              原因:输入调度超时(等待,因为触摸的窗口尚未完成   处理先前传递给它的输入事件。)                                              载荷:10.36 / 10.26 / 10.14                                              Android时间:[2016-10-03 09:53:17.565] [167215,125]                                              CPU使用率从0ms到6136ms之后:                                                97%18439 / com.example.luick.boat_rc:95%用户+ 1.6%内核/故障:277   次要                                                23%666 / system_server:18%用户+ 5%内核/故障:437次                                                5.7%163 / adbd:0.4%用户+ 5.2%内核/故障:569次                                                3.4%12471 / logcat:1.7%用户+ 1.6%内核                                                1.7%934 / com.android.phone:0.9%用户+ 0.8%内核/故障:153次                                                1.4%741 / com.android.systemui:1.1%用户+ 0.3%内核/故障:112次                                                0.8%18117 / kworker / 0:1:0%用户+ 0.8%内核                                                0%948 / com.mediatek.voicecommand:0%user + 0%kernel / faults:252 minor   6大专业                                                0%963 / com.mediatek.bluetooth:0%用户+ 0%内核/故障:175次                                                0%974 / com.tinno.gesture.phone:0%user + 0%kernel / faults:240 minor                                                0.3%18437 / kworker / 1:1:0%用户+ 0.3%内核                                                0%2 / kthreadd:0%用户+ 0%内核                                                0%63 / mmcqd / 0:0%用户+ 0%内核                                                0.1%68 / disp_config_upd:0%用户+ 0.1%内核                                                0%125 / debuggerd:0%用户+ 0%内核/故障:75次                                                0.1%132 / surfaceflinger:0%用户+ 0.1%内核                                                0%845 / tx_thread:0%用户+ 0%内核                                                0%916 / com.google.android.gms.persistent:0%用户+ 0%内核                                                0.1%12991 / kworker / u:0:0%用户+ 0.1%内核                                               + 0%18843 / migration / 2:0%用户+ 0%内核                                               + 0%18847 / kworker / 2:0:0%用户+ 0%内核                                               + 0%18848 / ksoftirqd / 2:0%用户+ 0%内核                                               + 0%18849 / kworker / 2:1:0%用户+ 0%内核                                              51%总计:44%用户+ 7.1%内核+ 0%爱荷华州

     

的logcat(警告):

                                                        10-03 09:58:15.311 666-687/? E/ActivityManager: writeStringToFile error:
     

/ sys / kernel / debug / tracing / tracing_on java.io.FileNotFoundException:   / sys / kernel / debug / tracing / tracing_on:open failed:ENOENT(没有这样的   文件或目录)10-03 09:58:15.312 666-687 /? E / ActivityManager:   writeStringToFile错误:   / SYS /内核/调试/粘合剂/ transaction_log_enable   java.io.FileNotFoundException:   / sys / kernel / debug / binder / transaction_log_enable:打开失败:ENOENT   (没有这样的文件或目录)

     

10-03 09:58:18.855 19017-19026 / com.example.luick.boat_rc E / dalvikvm:   致命的旋转暂停,倾销线程10-03 09:58:18.960   19017-19026 / com.example.luick.boat_rc E / dalvikvm:threadid = 4:卡在上面   threadid = 11,放弃

     

10-03 09:58:22.018 666-687 /? E / ANRManager:ANR in   com.example.luick.boat_rc(com.example.luick.boat_rc / .MainActivity)                                              原因:输入调度超时(等待,因为触摸的窗口尚未完成   处理先前传递给它的输入事件。)                                              载荷:9.41 / 9.62 / 9.89                                              Android时间:[2016-10-03 09:58:22.16] [167519,562]                                              CPU使用率从2080ms到-6692ms前:                                                97%19017 / com.example.luick.boat_rc:96%用户+ 1.1%内核/故障:319   次要                                                17%666 / system_server:13%用户+ 3.4%内核/故障:729次                                                4.9%163 / adbd:0.5%用户+ 4.3%内核/故障:773次                                                3.6%12471 / logcat:1.5%用户+ 2%内核                                                1.2%741 / com.android.systemui:0.9%用户+ 0.3%内核/故障:29小调                                                1.2%934 / com.android.phone:0.7%用户+ 0.4%内核/故障:2个未成年人                                                0.5%18117 / kworker / 0:1:0%用户+ 0.5%内核                                                0.4%132 / surfaceflinger:0.3%用户+ 0.1%内核                                                0%974 / com.tinno.gesture.phone:0%user + 0%kernel / faults:1 minor                                                0.3%19015 / kworker / 1:1:0%用户+ 0.3%内核                                                0.1%948 / com.mediatek.voicecommand:0.1%用户+ 0%内核                                                0.1%963 / com.mediatek.bluetooth:0%用户+ 0%内核                                                0.2%19011 / kworker / 0:0:0%用户+ 0.2%内核                                                0%6 / migration / 0:0%用户+ 0%内核                                                0%56 / bat_thread_kthr:0%用户+ 0%内核                                                0%63 / mmcqd / 0:0%用户+ 0%内核                                                0.1%68 / disp_config_upd:0%用户+ 0.1%内核                                                0%162 / em_svr:0%用户+ 0%内核                                                0.1%19174 / kworker / u:2:0%用户+ 0.1%内核                                               + 0%19295 / migration / 2:0%用户+ 0%内核                                               + 0%19296 / kworker / 2:0:0%用户+ 0%内核                                               + 0%19297 / ksoftirqd / 2:0%用户+ 0%内核                                               + 0%19298 / kworker / 2:1:0%用户+ 0%内核                                              51%总计:45%用户+ 6.3%内核10-03 09:58:22.020 666-687 /? E / ActivityManager:获取crashInfo   失败。

清单:

<?xml version="1.0" encoding="utf-8"?>

<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name="android.support.multidex.MultiDexApplication">
    <activity android:name=".MainActivity"
        android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyAL11W__n26lMvJ9y1Ea1jkvBR19REhE_g" />
</application>

MainActivity:

   package com.example.luick.boat_rc;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

import com.example.luick.boat_rc.de.ye.boat_conCONTROL.GPSTracker;

import android.location.Location;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.format.Formatter;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.Toast;

import com.example.luick.boat_rc.de.ye.boat_conCONTROL.CONNECT;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends AppCompatActivity implements SensorEventListener, OnMapReadyCallback {


    public static GoogleMap mMap;
    public static String RASP_IP = "192.168.42.1";
    public static boolean STATUS = false;
    public static SensorManager sensorManager;
    public static boolean KIPP = false;
    public static Switch S_K;
    public static ImageButton B_RELOAD;
    public static String MODE;
    public static ImageButton uf;
    public static ImageButton f;
    public static ImageButton s;
    public static ImageButton ra;
    public static Switch is;
    public static Switch tr;
    public static ImageView wifi_warn;
    private static final String TAG = "MainActivity";
    SupportMapFragment sMapF;
    GPSTracker gps;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        sMapF = SupportMapFragment.newInstance();
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        B_RELOAD = (ImageButton) findViewById(R.id.B_RELOAD);
        //i2.setEnabled(false);
        uf = (ImageButton) findViewById(R.id.uf);
        f = (ImageButton) findViewById(R.id.f);
        s = (ImageButton) findViewById(R.id.s);
        ra = (ImageButton) findViewById(R.id.r);
        s.setImageResource(R.drawable.up);
        f.setImageResource(R.drawable.upg2);
        uf.setImageResource(R.drawable.upg3);
        is = (Switch) findViewById(R.id.S_IS);
        tr = (Switch) findViewById(R.id.S_TR);
        wifi_warn = (ImageView) findViewById(R.id.wifi_warn);
        wifi_warn.setVisibility(View.INVISIBLE);
        Thread si = new Thread(new MainActivity.SEND_IP());
        si.start();
        is.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {
                    CONNECT.writer_sens_front.println("ON");
                    CONNECT.writer_sens_front.flush();
                    Toast.makeText(getApplicationContext(), "Inelligent_ON", Toast.LENGTH_SHORT).show();
                } else {
                    CONNECT.writer_sens_front.println("OFF");
                    CONNECT.writer_sens_front.flush();
                    Toast.makeText(getApplicationContext(), "Inelligent_OFF", Toast.LENGTH_SHORT).show();
                }

            }
        });
        tr.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {
                    CONNECT.writer_track.println("ON");
                    CONNECT.writer_track.flush();
                    Toast.makeText(getApplicationContext(), "TRACKING....", Toast.LENGTH_SHORT).show();
                } else {
                    CONNECT.writer_track.println("OFF");
                    CONNECT.writer_track.flush();
                    Toast.makeText(getApplicationContext(), "TRACKING_OFF", Toast.LENGTH_SHORT).show();
                }

            }
        });
        ra.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {

                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    KIPP = true;
                    ra.setImageResource(R.drawable.ar);

                } else if (event.getAction() == MotionEvent.ACTION_MOVE) {

                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    KIPP = false;
                    ra.setImageResource(R.drawable.dr);
                }

                return true;
            }
        });
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        android.support.v4.app.FragmentManager sFm = getSupportFragmentManager();
        sFm.beginTransaction().add(R.id.map, sMapF).commit();
        sMapF.getMapAsync(this);
        //gps = new GPSTracker(MainActivity.this);
       //Thread CAR_MAP_OBJECT = new Thread(new MainActivity.CAR_MAP_OBJECT());
        //CAR_MAP_OBJECT.start();

        //Thread USER_MAP_OBJECT = new Thread(new MainActivity.USER_MAP_OBJECT());
        //USER_MAP_OBJECT.start();
    }


    public void WIFI() {
        Context context = MainActivity.this;
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        int numberOfLevels = 5;
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
        if (Math.round(level) < 2) {
            wifi_warn.setVisibility(View.VISIBLE);
        } else {
            wifi_warn.setVisibility(View.INVISIBLE);
        }
    }

    public void B_RELOAD(View v) {
        Thread t = new Thread(new CONNECT());
        t.start();
    }

    public void s(View v) {
        MODE = "s";
        s.setImageResource(R.drawable.up);
        f.setImageResource(R.drawable.upg2);
        uf.setImageResource(R.drawable.upg3);
        if (STATUS == true) {
            CONNECT.writer_modi.println("s");
            CONNECT.writer_modi.flush();
            Toast.makeText(getApplicationContext(), "SLOW", Toast.LENGTH_SHORT).show();
        }
    }

    public void f(View v) {
        MODE = "f";
        s.setImageResource(R.drawable.upg);
        f.setImageResource(R.drawable.up2);
        uf.setImageResource(R.drawable.upg3);
        if (STATUS == true) {
            CONNECT.writer_modi.println("f");
            CONNECT.writer_modi.flush();
            Toast.makeText(getApplicationContext(), "FAST", Toast.LENGTH_SHORT).show();
        }
    }

    public void uf(View v) {
        MODE = "uf";
        s.setImageResource(R.drawable.upg);
        f.setImageResource(R.drawable.upg2);
        uf.setImageResource(R.drawable.up3);
        if (STATUS == true) {
            CONNECT.writer_modi.println("uf");
            CONNECT.writer_modi.flush();
            Toast.makeText(getApplicationContext(), "ULTRA_FAST", Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onSensorChanged(SensorEvent event) {


        WIFI();
        if (KIPP == true) {
            float output = ((event.values[1] - 1) * (500 - 1)) / (20 - 1) + 1;
            //output= ((input-minInput) * (maxOutput-minOutput)) / (maxInput-minInput) + minOutput;
            float output_eng = ((event.values[2] - 1) * (500 - 1)) / (20 - 1) + 1;
            //output= ((input-minInput) * (maxOutput-minOutput)) / (maxInput-minInput) + minOutput;

            int send = Math.round(output);

            int send_eng = Math.round(output_eng);

            if (STATUS == true) {
                //     if (send < 100 && send > -100) {
                //      CONNECT.writer_dir.println("15");
                //      CONNECT.writer_dir.flush();
                //  } else if (send > 100) {
                //      CONNECT.writer_dir.println("21");
                //      CONNECT.writer_dir.flush();

                //  } else if (send < -100) {
                //      CONNECT.writer_dir.println("10");
                //      CONNECT.writer_dir.flush();

                //Lenken
                if (MODE == "s" || MODE == null) {
                    if (send < 100 && send > -100) {
                        CONNECT.writer_dir.println("middle");
                        CONNECT.writer_dir.flush();
                    } else {
                        if (send > 100) {
                            CONNECT.writer_dir.println("right");
                            CONNECT.writer_dir.flush();
                        } else {
                            if (send < -100) {
                                CONNECT.writer_dir.println("left");
                                CONNECT.writer_dir.flush();
                            }
                        }
                    }
                }
                if (MODE == "f") {
                    if (send < 100 && send > -100) {
                        CONNECT.writer_dir.println("middle");
                        CONNECT.writer_dir.flush();
                    } else {
                        if (send > 100) {
                            CONNECT.writer_dir.println("right");
                            CONNECT.writer_dir.flush();
                        } else {
                            if (send < -100) {
                                CONNECT.writer_dir.println("left");
                                CONNECT.writer_dir.flush();
                            }
                        }
                    }
                }
                if (MODE == "uf") {
                    if (send < 100 && send > -100) {
                        CONNECT.writer_dir.println("middle");
                        CONNECT.writer_dir.flush();
                    } else {
                        if (send > 100) {
                            CONNECT.writer_dir.println("right");
                            CONNECT.writer_dir.flush();
                        } else {
                            if (send < -100) {
                                CONNECT.writer_dir.println("left");
                                CONNECT.writer_dir.flush();
                            }
                        }
                    }
                }
                //Lenken


                //Motor
                if (MODE == "s" || MODE == null) {

                    if (send_eng < 75 && send_eng > -75) {
                        CONNECT.writer_eng.println("0");
                        CONNECT.writer_eng.flush();
                    } else {
                        if (send_eng < -75) {
                            CONNECT.writer_eng.println("B");
                            CONNECT.writer_eng.println("150");
                            CONNECT.writer_eng.flush();
                        } else if (send_eng > 75) {
                            CONNECT.writer_eng.println("F");
                            CONNECT.writer_eng.println("150");
                            CONNECT.writer_eng.flush();

                        }
                    }
                } else if (MODE == "f") {

                    if (send_eng < 75 && send_eng > -75) {
                        CONNECT.writer_eng.println("0");
                        CONNECT.writer_eng.flush();
                    } else {
                        if (send_eng < -75) {
                            CONNECT.writer_eng.println("B");
                            CONNECT.writer_eng.println("150");
                            CONNECT.writer_eng.flush();
                        } else if (send_eng > 75) {
                            CONNECT.writer_eng.println("F");
                            CONNECT.writer_eng.println("180");
                            CONNECT.writer_eng.flush();

                        }
                    }

                } else if (MODE == "uf") {

                    if (send_eng < 75 && send_eng > -75) {
                        CONNECT.writer_eng.println("0");
                        CONNECT.writer_eng.flush();
                    } else {
                        if (send_eng < -75) {
                            CONNECT.writer_eng.println("B");
                            CONNECT.writer_eng.println("0");
                            CONNECT.writer_eng.flush();
                        } else if (send_eng > 75) {
                            CONNECT.writer_eng.println("F");
                            CONNECT.writer_eng.println("199");
                            CONNECT.writer_eng.flush();

                        }
                    }
                }

                //Motor
            }
        } else {
            if (STATUS == true) {
                CONNECT.writer_eng.println("0");
                CONNECT.writer_eng.flush();
                CONNECT.writer_dir.println("middle");
                CONNECT.writer_dir.flush();
            }
        }
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
    }

    @Override
    protected void onResume() {
        super.onResume();
        // register this class as a listener for the orientation and
        // accelerometer sensors
        sensorManager.registerListener(this,
                sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
                SensorManager.SENSOR_DELAY_NORMAL);
    }

    public class SEND_IP implements Runnable {


        @Override
        public void run() {
            while ((true)) {
                if (STATUS == true) {
                    WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
                    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
                    CONNECT.writer_con.println(ip);
                    CONNECT.writer_con.flush();
                }
            }
        }

    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap=googleMap;
    }
/*
    public class CAR_MAP_OBJECT implements Runnable{

        @Override
        public void run(){
            try {Thread.sleep(10000);} catch (InterruptedException e) {e.printStackTrace();}
            while (true){
                try {Thread.sleep(1000);} catch (InterruptedException e) {}
                MainActivity.mMap.clear();

                MarkerOptions car = new MarkerOptions();
                LatLng car_O = new LatLng(49.466786666666674,10.967413333333311);

                car.position(car_O);

                car.title("CAR");

                MainActivity.mMap.addMarker(car);

                MainActivity.mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(car_O, 16));
                //49.466786666666664
                //Longitude 10.967413333333331
            }
        }

    }*/

  /*  public class USER_MAP_OBJECT implements Runnable{

        @Override
        public void run(){
            try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}
            while (true){
                try {Thread.sleep(1000);} catch (InterruptedException e) {}
                if(gps.canGetLocation()){
                    double latitude = gps.getLatitude();
                    double longitude = gps.getLongitude();
                    Log.v(TAG,"Your Location is - \nLat: " + latitude + "\nLong: " + longitude);
                    //Location location = gps.getLocation();

                    //mMap.clear();

                    //MarkerOptions user = new MarkerOptions();

                    //user.position(new LatLng(location.getLatitude(), location.getLongitude()));

                    //user.title("You");

                    //mMap.addMarker(user);

                    //mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
                    //      new LatLng(location.getLatitude(), location.getLongitude()), 16));
                }else{
                    gps.showSettingsAlert();
                }
            }
        }

    }*/
}

Java代码只是MainActivity还有一些其他类,但我认为错误是在MainActivity中并由Google Maps引起。

感谢pcpriyanka的编辑:D

1 个答案:

答案 0 :(得分:0)

将这些权限添加到manifest.xml

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

你很高兴...