无法找到明确的活动类,kotlin

时间:2018-05-31 06:08:11

标签: android kotlin android-manifest

活动已在清单

中声明
 <activity
            android:name=".SplashActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


open class SplashActivity : AppCompatActivity() {
         override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_splash)
         }
}
  

流程:ge.goleta.taxi,PID:29708       java.lang.RuntimeException:无法启动活动ComponentInfo {ge.goleta.taxi/ge.goleta.taxi.SplashActivity}:android.content.ActivityNotFoundException:无法找到显式活动类{ge.goleta.taxi/int};你有没有在AndroidManifest.xml中声明这个活动?           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785)           在android.app.ActivityThread.-wrap12(ActivityThread.java)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1532)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:163)           在android.app.ActivityThread.main(ActivityThread.java:6342)           at java.lang.reflect.Method.invoke(Native Method)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:880)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)        引起:android.content.ActivityNotFoundException:无法找到显式活动类{ge.goleta.taxi/int};你有没有在AndroidManifest.xml中声明这个活动?           在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1812)           在android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)           在android.app.Activity.startActivityForResult(Activity.java:4399)           在android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)           在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)           在android.app.Activity.startActivityForResult(Activity.java:4358)           在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)           在android.app.Activity.startActivity(Activity.java:4682)           在android.app.Activity.startActivity(Activity.java:4650)           在ge.goleta.taxi.SplashActivity.onCreate(SplashActivity.kt:49)           在android.app.Activity.performCreate(Activity.java:6847)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)

1 个答案:

答案 0 :(得分:-1)

如下所示进行更改..

 class SplashActivity :AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_splash)
}
}

检查清单文件,就像这样在应用程序标记之间添加活动。

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".SplashActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

</activity>
</application>