1

I'm developing an Android application with Android Studio and since today I can no longer run the app because when Android Studio installs the apk on my device, the package installer crashes with the following message "Unfortunately, package installer has stopped". The strange thing is that when I run the application I can see for a second the main activity and its components but then everything crashes. This is the exception:

10-15 22:16:48.185 1793-1793/? E/AndroidRuntime: FATAL EXCEPTION: main 
    Process: com.android.packageinstaller, PID: 1793
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity}: java.lang.NullPointerException: Attempt to get length of null array
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
    at android.app.ActivityThread.access$900(ActivityThread.java:153)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5451)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
    at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.computePermissionGrantState(GrantPermissionsActivity.java:312)
    at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.updateDefaultResults(GrantPermissionsActivity.java:362)
    at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.onCreate(GrantPermissionsActivity.java:105)
    at android.app.Activity.performCreate(Activity.java:6323)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5451) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Thank you very much in advance

Melquiades
  • 8,316
  • 1
  • 27
  • 40
Federico Taschin
  • 1,183
  • 2
  • 8
  • 20
  • 1
    You get NullPointerException in your code when trying to get runtime permissions i guess. You should share some code. – Thracian Oct 15 '17 at 20:36
  • The installer is crashing which doesn't give us much information to go by. I suggest that you start a brand new project and try to run a basic Hello, World app. From there, gradually add features from your actual app in very small pieces, as small as possible. This will help you determine what feature causes the problem. – Code-Apprentice Oct 15 '17 at 20:50
  • If OP shares some code i can explain why it's not about instantiating may be it could be about instantiating the array that is null but most of the answers i see about the issues i wrote about or about granting permissions inside AndroidManifest.xml. – Thracian Oct 15 '17 at 21:28

1 Answers1

0

You have an issue with "granted permissions on runtime", basically you must grant permissions to use specific functionalities. Have a look here: https://developer.android.com/training/permis

Have a look at you manifest and check which of the "user-permissions" are required to check in runtime, if you have not user-permissions added, then now is the time https://developer.android.com/guide/topics/manifest/uses-permission-element.html. Then use the code provided in the first link after to check runtime permissions. Remember: ask permissions on runtime is required for Android 6.0 (API level 23) and above. On lower SDK (<=22), is enough adding the "user-permissions" into the manifest.

davthecoder
  • 589
  • 5
  • 20