我正在尝试使用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
的Manifest.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;
}
}
感谢您宝贵的时间!..
答案 0 :(得分:4)
org.achartengine.GraphicalActivity
,因为它是库的一部分。
将以下行添加到 project.properties 文件中,以启用自动合并清单。
manifestmerger.enabled=true
修改强>
我认为achartengine是一个图书馆项目。原来它是一个JAR。
您需要将活动添加到清单中:
<activity android:name="org.achartengine.GraphicalActivity" />
答案 1 :(得分:0)
您需要将活动添加到AndroidManifest.xml,如下所示:
<activity android:name="org.achartengine.GraphicalActivity"></activity>