The command adb shell am set-debug-app -w packagenamedoes not working to me, in place attach a debbug it close the process
adb shell am set-debug-app -w packagename