我正在尝试使用 achartengine 库在 android 中创建一个图形。运行模拟器后,它只显示“抱歉您的应用程序意外关闭。再试一次。强制关闭”
我只对 Manifest.xml 文件有疑问,我的清单文件是吗?如果不是,请让我清楚。
请找到我的来源、manifest.xml 和 logcat 以供参考
LOGCAT
08-22 11:47:05.763: D/AndroidRuntime(537): Shutting down VM
08-22 11:47:05.775: W/dalvikvm(537): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-22 11:47:05.783: E/AndroidRuntime(537): FATAL EXCEPTION: main
08-22 11:47:05.783: E/AndroidRuntime(537): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.graphs_test/com.example.graphs_test.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.graphs_test/org.achartengine.GraphicalActivity}; have you declared this activity in your AndroidManifest.xml?
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.os.Looper.loop(Looper.java:123)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 11:47:05.783: E/AndroidRuntime(537): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 11:47:05.783: E/AndroidRuntime(537): at java.lang.reflect.Method.invoke(Method.java:521)
08-22 11:47:05.783: E/AndroidRuntime(537): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 11:47:05.783: E/AndroidRuntime(537): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 11:47:05.783: E/AndroidRuntime(537): at dalvik.system.NativeStart.main(Native Method)
08-22 11:47:05.783: E/AndroidRuntime(537): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.graphs_test/org.achartengine.GraphicalActivity}; have you declared this activity in your AndroidManifest.xml?
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.Activity.startActivityForResult(Activity.java:2817)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.Activity.startActivity(Activity.java:2923)
08-22 11:47:05.783: E/AndroidRuntime(537): at com.example.graphs_test.MainActivity.onCreate(MainActivity.java:21)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-22 11:47:05.783: E/AndroidRuntime(537): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-22 11:47:05.783: E/AndroidRuntime(537): ... 11 more
清单.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.graphs_test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = buildIntent();
startActivity(intent);
}
public Intent buildIntent() {
int[] values = new int[] { 5, 15, 25, 50, 75 };
String[] bars = new String[] {"Francesca's", "King of Clubs",
"Zen Lounge", "Tied House", "Molly Magees"};
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA,
Color.YELLOW, Color.CYAN };
CategorySeries series = new CategorySeries("Pie Chart");
DefaultRenderer dr = new DefaultRenderer();
for (int v=0; v<5; v++){
series.add(bars[v], values[v]);
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(colors[v]);
dr.addSeriesRenderer(r);
}
dr.setZoomButtonsVisible(true);
dr.setZoomEnabled(true);
dr.setChartTitleTextSize(20);
return ChartFactory.getPieChartIntent(
this, series, dr, "Pie of bars");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
感谢您宝贵的时间!..