简体   繁体   English

安装Android 6.0.1后,调试时应用崩溃

[英]App crashes while debugging, after installed Android 6.0.1

This might sound like a weird one. 这听起来很奇怪。 I am a beginner coder and right now I am making an app that has login/register activities. 我是一名初学者,现在我正在制作一个具有登录/注册活动的应用程序。 It worked fine on Samsung Galaxy S3 (Android version 4.3.), but a week ago I installed CyanogenMod and now I have Android version 6.0.1. 它在Samsung Galaxy S3(Android 4.3版)上运行良好,但是一周前我安装了CyanogenMod,现在安装的是Android 6.0.1版。

Here is the problem - if I run the app it opens with a popup alert " Unfortunately, MyFirstApp has stopped. ", and then when I click OK button it opens the login window, as it should. 这是问题所在 -如果我运行该应用程序,则它会弹出警告“ 不幸的是,MyFirstApp已停止。 ”,然后,当我单击“ 确定”按钮时,它将按需打开登录窗口。 After I try to enter credentials to login or register it shows my default error message that it cannot connect to server. 在尝试输入凭据进行登录或注册后,它显示了我无法连接到服务器的默认错误消息。 I tried this on the second phone, same model Samsung Galaxy S3, but with Android 4.3 it works without a problem. 我在第二部手机(相同型号的三星Galaxy S3)上尝试过此功能,但在Android 4.3上可以正常使用。

I tried debugging the app but it crashes immediately, with a console message: 我尝试调试该应用程序,但它立即崩溃,并显示一条控制台消息:

Connected to the target VM, address: 'localhost:8613', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8613', transport: 'socket'

My AppConfig: 我的AppConfig:

// Default configuration emulator/device urls
// private static String base_URL = "http://10.0.2.2/myfirstapp/";
private static String base_URL = "http://192.168.0.103/myfirstapp/";

// Server user login url
public static String URL_LOGIN = base_URL + "login.php";

// Server user register url
public static String URL_REGISTER = base_URL + "register.php";

I have enabled debugging on the phone. 我已在手机上启用调试。

Event log: 事件日志:

12:03:55 Executing tasks: [:app:incrementalDebugSupportDex]
12:03:56 Gradle build finished in 1s 375ms

Console: 安慰:

07/28 12:03:56: Launching app
No local changes, not deploying APK
$ adb shell am start -D -n "mcvc.kemo.myfirstapp/mcvc.kemo.myfirstapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for application to come online: mcvc.kemo.myfirstapp | mcvc.kemo.myfirstapp.test
Waiting for application to come online: mcvc.kemo.myfirstapp | mcvc.kemo.myfirstapp.test
Waiting for application to come online: mcvc.kemo.myfirstapp | mcvc.kemo.myfirstapp.test
Waiting for application to come online: mcvc.kemo.myfirstapp | mcvc.kemo.myfirstapp.test
Connecting to mcvc.kemo.myfirstapp
Connected to the target VM, address: 'localhost:8609', transport: 'socket'
// Here I click on the OK button when popup says it stopped working
Disconnected from the target VM, address: 'localhost:8609', transport: 'socket'

Manifest: 表现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mcvc.kemo.myfirstapp">

<permission
    android:name="devncode.kemo.myfirstapp.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="devncode.kemo.myfirstapp.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission
    android:name="com.example.gcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

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

<application
    android:name=".app.AppController"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!--Login/Register activities-->
    <activity
        android:name=".loginregister.LoginActivity"
        android:theme="@style/AppTheme.Dark" />
    <activity
        android:name=".loginregister.RegisterActivity"
        android:theme="@style/AppTheme.Dark" />

   ...

Dependencies: 依存关系:

  compile 'com.android.support:appcompat-v7:23.1.1' 
  compile 'com.android.support:design:23.1.1' 
  compile 'com.google.android.gms:play-services:8.3.0' 
  compile 'com.jakewharton:butterknife:6.1.0' 
  compile 'de.hdodenhof:circleimageview:1.3.0' 
  compile 'com.mcxiaoke.volley:library-aar:1.0.0'

Most probably the problem here is with new Android permission model . 这里最有可能的问题是新的Android权限模型 Since API 23 (Android 6.0) you have to ask user for some permissions directly before using the features you need. 从API 23(Android 6.0)开始,您必须在使用所需功能之前直接向用户询问一些权限。 So you should either target API 22 or below or implement run time permission. 因此,您应该以API 22或更低版本为目标,或者实现运行时权限。 To be hundred percent sure what causes the problem you should view logs (Android Monitor -> logcat, and don't forget to clear tag text box, you may also choose "Error" level to see only errors). 为了百分百确定是什么导致了问题,您应该查看日志(Android Monitor-> logcat,并且不要忘记清除标签文本框,也可以选择“错误”级别以仅查看错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM