无法显示的android图android

2023-09-07 02:02:59 作者:酒和泪入喉

我想创建Android中使用achartengine库图。 得到一个模拟器的运行之后它只是显示的抱歉,您的应用程序意外closed.try again.force接近

I am trying to create a graph in android using achartengine library. After getting run of an emulator its just showing "sorry your app unexpectedly closed.try again.force close"

我只有在Manifest.xml文件一个疑问,就是我的清单文件怀特?如果不是,请让我清楚。

I have a doubt only on Manifest.xml file, is my manifest file wight?if not please make me clear.

请找我的消息来源,以及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;
}
}

感谢您的precious时间!..

Thanks for your precious time!..

推荐答案

org.achartengine.GraphicalActivity 未找到您的清单,因为这是图书馆的一部分。

org.achartengine.GraphicalActivity wasn't found in your manifest because it is part of the library.

添加下面一行到你的 project.properties 的文件,使舱单自动合并。

Add the following line to your project.properties file to enable automatic merging of manifests.

manifestmerger.enabled=true 

编辑:

我想achartengine是库项目。原来这是一个JAR文件。

I thought achartengine was a library project. Turns out it's a JAR.

您需要将活动添加到您的清单:

You need to add the activity to your manifest:

<activity android:name="org.achartengine.GraphicalActivity" />