Launcher Activity Issue Android

时间:2016-04-07 10:48:50

标签: android android-activity manifest launcher

I created a splash screen for my android application. In my AndroidManifest I set the SplashScreen Activity as Launcher and action as MAIN. After that I changed the HomeActivity's intentfilter. Here is my android manifest file:

<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>

I have both these activities inside the default package. Now, when I try to test the application in device, I get the following error:

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

This is how my project structure looks like:

src
-com.sdz.myapp
----ActivityHome
----SplashScreenActivity

I restarted android studio but still the error is there. I dont know what is causing this.

4 个答案:

答案 0 :(得分:2)

我也碰到了这个。我实际上不得不从设备上卸载apk才能工作......这真的很奇怪,因为应用程序没有显示在我手机上的应用程序列表中。

这就是我的所作所为:

  1. 打开命令行
  2. 让'adb devices'确保我的设备已连接
  3. 运行'adb uninstall'替换为“com.whatever.blah”
  4. 您应该看到一条消息说它已成功卸载
  5. 再次尝试从Android Studio安装,它应该可以正常工作
  6. 我不知道它是如何进入这种奇怪的状态的。 : - /

答案 1 :(得分:1)

请使用全名和第一个清洁项目更改活动代码中的android:name值。之后尝试再次运行您的应用程序

<activity android:name="com.sdz.myapp.SplashScreenActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

答案 2 :(得分:0)

我偶尔会遇到同样的问题。解决方案是构建APK(菜单“Build&gt; Build APK”)并在手机中手动安装。之后,错误消失。

答案 3 :(得分:0)

我尝试了以上所有方法,甚至删除了build文件夹,但仍然无法正常工作。对我来说,解决方案是:在您的Android Studio上,转到“文件”->“使用Gradle文件同步项目”