ERROR / dalvikvm(1120):JIT代码缓存已满

时间:2013-10-28 20:36:07

标签: java android linux

我有public class MapActivity extends Activity implements LocationListene我要加载的onCreate方法:

protected void onCreate(Bundle savedInstanceState) {

        try {
            super.onCreate(savedInstanceState);   
            setContentView(R.layout.mapview);

            ...
        }
}

mapview.xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:id="@+id/ll_mapView"
              android:background="@android:color/white">

   <another_working_layout_here>

    <map.MyLocation
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    </map.MyLocation>

</LinearLayout>

作为一个加载来自类的视图:

public class MyLocation extends View {
    Paint paint = new Paint();

    public MyLocation(Context context) {
        super(context);
    }

    @Override
    protected void onDraw(Canvas canvas) {

        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawCircle(100, 100, 100, paint);
        this.invalidate();
    }
}

一般情况下,我希望在mapActivity中使用onLocationChanged方法从android gps中读取,添加更改点,然后使用onDraw方法在class MyLocation extends View中完成的扩展视图上打印它。我确信我不完全理解这个概念,但不知道如何以不同的方式做到这一点。

我的错误是:

10-28 16:06:40.147: ERROR/myException(2869): android.view.InflateException: Binary XML file line #26: Error inflating class map.MyLocation
10-28 16:07:06.478: ERROR/ActivityManager(1120): ANR in com.example.gps_3 (com.example.gps_3/activities.MapActivity)
        Reason: keyDispatchingTimedOut
        Load: 0.26 / 0.25 / 0.76
        CPU usage from 39586ms to 535ms ago:
        2.2% 950/adbd: 0% user + 2.2% kernel
        0% 932/yaffs-bg-1: 0% user + 0% kernel
        0.1% 2869/com.example.gps_3: 0% user + 0.1% kernel / faults: 18 minor
        0.1% 1120/system_server: 0% user + 0% kernel
        0% 1391/com.android.phone: 0% user + 0% kernel / faults: 92 minor
        0% 930/yaffs-bg-1: 0% user + 0% kernel
        0% 1281/com.android.systemui: 0% user + 0% kernel / faults: 6 minor
        0% 1404/com.android.launcher: 0% user + 0% kernel
        0% 2789/com.android.browser: 0% user + 0% kernel / faults: 89 minor
        48% TOTAL: 0.6% user + 45% kernel + 1.8% softirq
        CPU usage from 403ms to 914ms later:
        1.9% 1120/system_server: 0% user + 1.9% kernel
        100% TOTAL: 0% user + 100% kernel
10-28 16:12:04.312: ERROR/dalvikvm(1120): JIT code cache full
10-28 16:12:04.322: ERROR/InputDispatcher(1120): channel 'b353cf20 com.example.gps_3/activities.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-28 16:12:04.322: ERROR/InputDispatcher(1120): channel 'b350af88 com.example.gps_3/activities.MapActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-28 16:12:05.092: ERROR/jdwp(2914): Failed sending reply to debugger: Broken pipe
10-28 16:13:04.613: ERROR/myException(2914): android.view.InflateException: Binary XML file line #26: Error inflating class map.MyLocation

修改

在:

中调用异常
  @Override
    protected void onCreate(Bundle savedInstanceState) {

        try {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.mapview);
            myLocationManager = (LocationManager) this.getSystemService(this.LOCATION_SERVICE);
            myLocationLister = this;
            myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, myLocationLister);
        } catch (Exception e) {
            Log.e("myException", e.toString());      
        }

    }

setContentView(R.layout.mapview);行。

我很感激任何想法。感谢

问题在于缺少构造函数:

public MyLocation(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

已连接的有用主题: Do I need all three constructors for an Android custom view?

0 个答案:

没有答案