0

I have an android app that is working perfectly when deployed via android studio but when I copy the generated apk from the output folder (app\build\outputs\apk) and install it on the same phone the app crashes up on loading.

Even that upon installation the OS says that the app does not require any special permissions even though I have these in the manifest file:

  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Hasan Shouman
  • 2,162
  • 1
  • 20
  • 26
  • 1
    "the app crashes up on loading" -- use LogCat to examine the Java stack trace associated with your crash: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare Jul 28 '17 at 13:11
  • before taking apk from app\build\outputs\apk, Goto Build>Build APK then then try to install in device – Sunil P Jul 28 '17 at 13:12
  • Have you included runtime permissions for some of those? I know you need runtime permissions for `READ_CONTACTS` at least – cjnash Jul 28 '17 at 13:18
  • @SunilP Thank you, this was the solution, please add it to accept it. – Hasan Shouman Jul 28 '17 at 13:52
  • welcome buddy @HasanShouman – Sunil P Jul 29 '17 at 05:07

1 Answers1

1

You need to explicitly ask the user to provide permission to access location and contacts. This is an update that was added to lollipop/Marshmallow.

You might have to do something like this.

@Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        if (requestCode == PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION
                && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
           // The user has granted permission to access location
        } else {
            // The user has not granted permission(notify the user that certain features will not work for the app if the permission is not granted)
        }
    }