安装 Android 6.0.1 后,应用程序在调试时崩溃
App crashes while debugging, after installed Android 6.0.1
这听起来很奇怪。我是一名初学者编码员,现在我正在制作一个具有 login/register 活动的应用程序。它在 Samsung Galaxy S3(Android 4.3 版)上运行良好,但一周前我安装了 CyanogenMod,现在我有 Android 6.0.1 版。
这是问题所在 - 如果我 运行 打开应用程序时弹出警告“不幸的是,MyFirstApp 已停止。",然后当我单击 确定 按钮时,它会按原样打开登录 window。在我尝试输入凭据以登录或注册后,它显示我的默认错误消息,即它无法连接到服务器。我在第二个 phone 上试过这个,相同型号的三星 Galaxy S3,但是 Android 4.3 没有问题。
我尝试调试该应用程序,但它立即崩溃,并显示一条控制台消息:
Connected to the target VM, address: 'localhost:8613', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8613', transport: 'socket'
我的 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";
我在 phone 上启用了调试。
事件日志:
12:03:55 Executing tasks: [:app:incrementalDebugSupportDex]
12:03:56 Gradle build finished in 1s 375ms
控制台:
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'
清单:
<?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" />
...
依赖关系:
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'
这里的问题很可能是 new Android permission model。从 API 23 (Android 6.0) 开始,您必须在使用您需要的功能之前直接询问用户一些权限。因此,您应该以 API 22 或以下为目标,或者实施 运行 时间许可。
要百分百确定导致问题的原因,您应该查看日志(Android 监控 -> logcat,并且不要忘记清除标签文本框,您也可以选择 "Error" 级别来只看到错误)。
这听起来很奇怪。我是一名初学者编码员,现在我正在制作一个具有 login/register 活动的应用程序。它在 Samsung Galaxy S3(Android 4.3 版)上运行良好,但一周前我安装了 CyanogenMod,现在我有 Android 6.0.1 版。
这是问题所在 - 如果我 运行 打开应用程序时弹出警告“不幸的是,MyFirstApp 已停止。",然后当我单击 确定 按钮时,它会按原样打开登录 window。在我尝试输入凭据以登录或注册后,它显示我的默认错误消息,即它无法连接到服务器。我在第二个 phone 上试过这个,相同型号的三星 Galaxy S3,但是 Android 4.3 没有问题。
我尝试调试该应用程序,但它立即崩溃,并显示一条控制台消息:
Connected to the target VM, address: 'localhost:8613', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8613', transport: 'socket'
我的 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";
我在 phone 上启用了调试。
事件日志:
12:03:55 Executing tasks: [:app:incrementalDebugSupportDex]
12:03:56 Gradle build finished in 1s 375ms
控制台:
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'
清单:
<?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" />
...
依赖关系:
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'
这里的问题很可能是 new Android permission model。从 API 23 (Android 6.0) 开始,您必须在使用您需要的功能之前直接询问用户一些权限。因此,您应该以 API 22 或以下为目标,或者实施 运行 时间许可。 要百分百确定导致问题的原因,您应该查看日志(Android 监控 -> logcat,并且不要忘记清除标签文本框,您也可以选择 "Error" 级别来只看到错误)。