【问题标题】:Android Studio App crashes when I'm starting it on handy without debugger当我在没有调试器的情况下方便地启动 Android Studio 应用程序时崩溃
【发布时间】:2017-02-11 02:58:24
【问题描述】:

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

Logcat(错误):

10-03 09:53:12.172 666-680/? E/传感器:poll() 失败(中断 系统调用)10-03 09:53:15.802 666-680/? E/传感器:poll() 失败 (中断的系统调用)10-03 09:53:17.128 18439-18520/com.example.luick.boat_rc E/dalvikvm:致命 自旋挂起,转储线程 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/ANR经理: com.example.luick.boat_rc 中的 ANR (com.example.luick.boat_rc/.MainActivity) 原因:输入调度超时(等待,因为触摸的窗口还没有完成 处理之前传递给它的输入事件。) 负载:10.36 / 10.26 / 10.14 安卓时间:[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% 用户 + 0% 内核/故障:252 次要 6个专业 0% 963/com.mediatek.bluetooth:0% 用户 + 0% 内核/故障:175 次小 0% 974/com.tinno.gesture.phone:0% 用户 + 0% 内核/故障:240 次 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/调试器: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% iowait

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:打开失败:ENOENT(没有这样的 文件或目录)10-03 09:58:15.312 666-687/?电子/活动管理器: writeStringToFile 错误: /sys/kernel/debug/binder/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 在 com.example.luick.boat_rc (com.example.luick.boat_rc/.MainActivity) 原因:输入调度超时(等待,因为触摸的窗口还没有完成 处理之前传递给它的输入事件。) 负载:9.41 / 9.62 / 9.89 安卓时间:[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% 用户 + 0% 内核/故障:1 次轻微 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 地图引起。

感谢 pcpriyanka 编辑:D

【问题讨论】:

  • 尝试检查GithubSO question 是否可以帮助您。只需尝试遵循提供的不同解决方案即可。此外,请确保您为此项目使用 Android Studio,并尝试清理或重建项目本身。

标签: android google-maps debugging


【解决方案1】:

将这些权限添加到 manifest.xml

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

你很高兴..

【讨论】:

  • 您要访问哪个文件?
  • 我不明白你的回答..我不想访问任何文件:}
  • 你能告诉我你在哪里得到这个错误吗?发布你的java代码
  • 我不知道问题出在哪里!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-30
  • 2013-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-17
相关资源
最近更新 更多