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

时间:2016-07-28 09:56:43

标签: javascript android debugging android-studio cyanogenmod

这可能听起来像一个奇怪的。我是初学者编码器,现在我正在制作一个具有登录/注册活动的应用程序。它在三星Galaxy S3(Android版本4.3。)上运行良好,但一周前我安装了CyanogenMod,现在我有Android版本6.0.1。

以下是问题 - 如果我运行应用程序,则会打开并显示弹出警告" 不幸的是,MyFirstApp已停止。 ",然后当我点击确定按钮时,它会打开登录窗口,就像它应该的那样。在我尝试输入登录或注册凭据后,它显示我无法连接到服务器的默认错误消息。我在第二款手机上试过这个,同样型号的三星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";

我已启用手机调试功能。

事件日志:

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'

1 个答案:

答案 0 :(得分:2)

这里的问题很可能是new Android permission model。从API 23(Android 6.0)开始,您必须在使用所需功能之前直接询问用户某些权限。因此,您应该定位API 22或更低版本,或者实现运行时权限。 要百分之百确定导致问题的原因,您应该查看日志(Android Monitor - &gt; logcat,并且不要忘记清除标记文本框,您也可以选择“错误”级别以仅查看错误)。