我为我的 Android 应用程序创建了一个启动屏幕。在我的 AndroidManifest 中,我将 SplashScreen Activity 设置为 Launcher,将操作设置为 MAIN。之后我更改了 HomeActivity 的 Intent 过滤器。 这是我的 Android list 文件:
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashScreenActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ActivityHome"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.ACTIVITHOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".Receivers.NetworkReceiver"></receiver>
</application>
我在默认包中拥有这两项 Activity 。现在,当我尝试在设备中测试应用程序时,出现以下错误:
Error while executing: am start -n "com.sdz.myapp/com.sdz.myapp.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sdz.myapp/.SplashScreenActivity }
Error type 3
Error: Activity class {com.sdz.myapp/com.sdz.myapp.SplashScreenActivity} does not exist.
Error while Launching activity
这就是我的项目结构:
src
-com.sdz.myapp
----ActivityHome
----SplashScreenActivity
我重新启动了android studio,但错误仍然存在。我不知道是什么原因造成的。
最佳答案
我也遇到过这个问题。实际上,我必须先从设备上卸载该 apk,然后它才能工作...这真的很奇怪,因为该应用程序没有显示在我手机上的应用程序列表中。
这就是我所做的:
- 打开命令行
- 运行“adb devices”以确保我的设备已连接
- 运行“adb uninstall”替换为“com.whatever.blah”
- 您应该会看到一条消息,表明已成功卸载
- 再次尝试从 Android Studio 安装,它应该可以工作
我不知道它是如何进入这种奇怪的状态的。 :-/
关于android - Android 启动器 Activity 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36473934/