0
我嘗試在android 2.2中使用appcompat支持actionbar,但是當我構建應用程序時,崩潰 首先,我將AppCompat添加爲庫。 這是我的Splash.Class
;添加appcompat後2.2在應用程序崩潰
package com.skyline.faceball;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
public class Splash extends ActionBarActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
startActivity(new Intent(Splash.this, Main.class));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.splash, menu);
return true;
}
}
和manifast我修改成:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.skyline.faceball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat" >
<activity
android:name="com.skyline.faceball.Splash"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.skyline.faceball.Main"
android:label="@string/title_activity_main" >
</activity>
</application>
</manifest>
,看我的日誌:
09-26 01:08:40.779: E/AndroidRuntime(501): FATAL EXCEPTION: main
09-26 01:08:40.779: E/AndroidRuntime(501): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.skyline.faceball/com.skyline.faceball.Splash}: java.lang.ClassNotFoundException: com.skyline.faceball.Splash in loader dalvik.system.PathClassLoader[/data/app/com.skyline.faceball-1.apk]
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.os.Looper.loop(Looper.java:123)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-26 01:08:40.779: E/AndroidRuntime(501): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 01:08:40.779: E/AndroidRuntime(501): at java.lang.reflect.Method.invoke(Method.java:521)
09-26 01:08:40.779: E/AndroidRuntime(501): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-26 01:08:40.779: E/AndroidRuntime(501): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-26 01:08:40.779: E/AndroidRuntime(501): at dalvik.system.NativeStart.main(Native Method)
09-26 01:08:40.779: E/AndroidRuntime(501): Caused by: java.lang.ClassNotFoundException: com.skyline.faceball.Splash in loader dalvik.system.PathClassLoader[/data/app/com.skyline.faceball-1.apk]
09-26 01:08:40.779: E/AndroidRuntime(501): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
09-26 01:08:40.779: E/AndroidRuntime(501): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
09-26 01:08:40.779: E/AndroidRuntime(501): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-26 01:08:40.779: E/AndroidRuntime(501): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-26 01:08:40.779: E/AndroidRuntime(501): ... 11 more
andmy Main.Class
package com.skyline.faceball;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
public class Main extends ActionBarActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().setTitle("Main");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
如何刪除這個問題? 謝謝。
發佈部分清單中,你聲明的活動。 – 2014-09-25 21:53:15
看到我的更新... – 2014-09-25 21:53:35
@ShobhitPuri看到我的更新 – 2014-09-25 21:55:02