1

我正在使用 Android Studio 开发一个 Android 应用程序,从今天起我无法再运行该应用程序,因为当 Android Studio 在我的设备上安装 apk 时,包安装程序崩溃并显示以下消息“不幸的是,包安装程序已停止”。奇怪的是,当我运行应用程序时,我可以看到主要活动及其组件,但随后一切都崩溃了。这是一个例外:

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)

非常感谢您提前

4

1 回答 1

0

您对“在运行时授予权限”有疑问,基本上您必须授予使用特定功能的权限。看看这里:https ://developer.android.com/training/permis

看看你的清单并检查在运行时检查需要哪些“用户权限”,如果你没有添加用户权限,那么现在是时候https://developer.android.com/guide/topics /manifest/uses-permission-element.html。然后使用第一个链接中提供的代码检查运行时权限。请记住:Android 6.0(API 级别 23)及更高版本需要在运行时询问权限。在较低的 SDK (<=22) 上,将“用户权限”添加到清单中就足够了。

于 2017-10-15T20:56:22.163 回答