當我啓動應用程序時,它會強制關閉。活動無法投射到android.app.Application
這是logcat的:
java.lang.RuntimeException: Unable to instantiate application com.blocktrekacademy.officialblocktrek.Authentication: java.lang.ClassCastException: com.blocktrekacademy.officialblocktrek.Authentication cannot be cast to android.app.Application
[修訂]:這是我的AndroidManifest.xml中:
...
<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">
<activity
android:name=".Authentication"
android:label="@string/title_activity_authentication"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
這是我Authentication.java
package com.blocktrekacademy.officialblocktrek;
import ...
public class Authentication extends AppCompatActivity {
...
那麼'com.blocktrekacademy.officialblocktrek.Authentication'的聲明是什麼樣的? –
'com.blocktrekacademy.officialblocktrek.Authentication'擴展了'Application'嗎? –
它擴展了AppCompatActivity – Axis