0
votes

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.

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. 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.

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:

// 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'
1
put your error log here!!!!!!!!!!!!!!!!! - Vishal Patoliya ツ
what does the error message say? - Viral Patel
@AndriodMechanic The weird thing is it says nothing. Even when it crashes my event log is: 12:03:55 Executing tasks: [:app:incrementalDebugSupportDex] 12:03:56 Gradle build finished in 1s 375ms - Banana
Is this happening every time you click on the app launch icon or just after you click run inside android studio? - Nir Duan
@Nir Duran when I run it from android studio or launch it by clicking on the icon it shows popup window that it stopped working and then when I click ok it opens login window, but I cannot log in. When I debug it from android studio it just crashes, without any error messages. - Banana

1 Answers

2
votes

Most probably the problem here is with new Android permission model. Since API 23 (Android 6.0) you have to ask user for some permissions directly before using the features you need. So you should either target API 22 or below or implement run time permission. 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).