AndroidStudio报错java.lang.SecurityException: Permission Denial:

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuliang756071448/article/details/78227320

新建了一个项目,每次都能正常运行,但是无论是退出app,还是按返回键回到桌面,就再也进不了app了, 错误信息:

Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.nailbeauty.miss/.MainActivity bnds=[360,832][532,1024] }. Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity. tag=ShortcutInfo(title=Nail Beautyintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.nailbeauty.miss/.MainActivity bnds=[360,832][532,1024] }id=86 type=0 container=-100 screen=1 cellX=2 cellY=4 spanX=1 spanY=1 category=-1 dropPos=null) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.nailbeauty.miss/.MainActivity bnds=[360,832][532,1024] }
java.lang.SecurityException: Permission Denial: starting Intent {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.nailbeauty.miss/.MainActivity bnds=[360,832][532,1024] } from ProcessRecord{10bc7728 1907:com.meizu.flyme.launcher/u0a12} (pid=1907, uid=10012) not exported from uid 10129
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2674)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1526)
at android.app.Activity.startActivityForResult(Activity.java:3850)
at android.app.Activity.startActivityForResult(Activity.java:3799)
at com.meizu.flyme.launcher.Launcher.startActivityForResult(SourceFile:3904)
at android.app.Activity.startActivity(Activity.java:4170)
at android.app.Activity.startActivity(Activity.java:4101)
at com.meizu.flyme.launcher.Launcher.a(SourceFile:4979)
at com.meizu.flyme.launcher.Launcher.b(SourceFile:5017)
at com.meizu.flyme.launcher.Launcher.onClick(SourceFile:4640)
at android.view.View.performClick(View.java:4909)
at android.view.View$PerformClick.run(View.java:20390)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5883)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1119)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)

贴上AndroidManifest中的相关代码:

        <activity
            android:name=".SplashActivity"
            android:screenOrientation="portrait"
            android:theme="@style/MyAppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"/>

网上的两个方法都没能解决该问题:
1、直接把MainActivity作为入口,也就是不需要SplashActivity的话,是可以正常进入app的,没有问题,但是明显不合我们的要求
2、添加一行代码 android:exported=”true”如下:

        <activity
            android:name="com.nailbeauty.miss.MainActivity"
            android:launchMode="singleTask"
            android:exported="true"
            android:screenOrientation="portrait"/>

添加的这个属性意思为另一个应用可以调起当前应用,但是跟我们的需求没有任何关系

解决办法

最后发现是因为手机上已经安装了一个集成了LeakCanary的debug包,同时当前应用也是集成了LeakCanary的debug包,所以直接卸载另一个debug包就好了。

猜你喜欢

转载自blog.csdn.net/wuliang756071448/article/details/78227320