Sunday, 15 June 2014

android - SherlockFragmentActivity java.lang.NoSuchFieldError when setting content view at the beginning -



android - SherlockFragmentActivity java.lang.NoSuchFieldError when setting content view at the beginning -

when starting activity, i'm retrieving next error:

02-14 09:51:30.898: v/violazioniactivity(7510): oncreate before 2130903076 02-14 09:51:30.913: d/dalvikvm(7510): dexopt: couldn't find static field lit/helian/violazioni/r$id;.btn1 02-14 09:51:30.913: w/dalvikvm(7510): vfy: unable resolve static field 6831 (btn1) in lit/helian/violazioni/r$id; 02-14 09:51:30.913: d/dalvikvm(7510): vfy: replacing opcode 0x60 @ 0x0015 02-14 09:51:30.913: d/dalvikvm(7510): dexopt: couldn't find static field lit/helian/violazioni/r$id;.btn2 02-14 09:51:30.913: i/dalvikvm(7510): dexopt: unable optimize static field ref 0x1ab0 @ 0x30 in lit/helian/violazioni/fe/ui/violazionidashboardfragment;.oncreateview 02-13 18:14:32.565: e/androidruntime(26290): fatal exception: main 02-13 18:14:32.565: e/androidruntime(26290): java.lang.nosuchfielderror: it.helian.violazioni.r$id.btn1 02-13 18:14:32.565: e/androidruntime(26290): @ it.helian.violazioni.fe.ui.violazionidashboardfragment.oncreateview(violazionidashboardfragment.java:38) 02-13 18:14:32.565: e/androidruntime(26290): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:846) 02-13 18:14:32.565: e/androidruntime(26290): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1061) 02-13 18:14:32.565: e/androidruntime(26290): @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1160) 02-13 18:14:32.565: e/androidruntime(26290): @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:272) 02-13 18:14:32.565: e/androidruntime(26290): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:669)

main activity

bundle it.helian.violazioni.be.activity; import it.helian.violazioni.r; import android.os.bundle; import android.util.log; import com.actionbarsherlock.app.sherlockfragmentactivity; import com.googlecode.androidannotations.annotations.eactivity; //@eactivity(resname="activity_violazioni") @eactivity public class violazioniactivity extends sherlockfragmentactivity { public static final string tag = "violazioniactivity"; @override public void oncreate(bundle savedinstancestate) { log.v(tag, "oncreate before " + r.layout.activity_violazioni); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_violazioni); log.v(tag, "oncreate after"); } }

r.layout.activity_violazioni

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/home_root" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <fragment android:id="@+id/fragment_dashboardz" android:name="it.helian.violazioni.fe.ui.violazionidashboardfragment" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" />

it.helian.violazioni.fe.ui.violazionidashboardfragment

public class violazionidashboardfragment extends sherlockfragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { system.out.println("check 2a"); view root = inflater.inflate(r.layout.main_menu, container); system.out.println("check 2b"); btn1 = (mainbutton) root.findviewbyid(r.id.btn1); system.out.println("check 3"); btn1.setonclicklistener( new view.onclicklistener() { public void onclick(view view) { firetrackerevent(event_click_classica); } }); btn2 =(mainbutton) root.findviewbyid(r.id.btn2); btn2.setonclicklistener( new view.onclicklistener() { public void onclick(view view) { firetrackerevent(event_click_classica_anpr); } }); }

main_menu.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="1dp" android:weightsum="101" > <linearlayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="10" /> <linearlayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="27" android:orientation="horizontal" android:weightsum="10" > <it.helian.violazioni.fe.ui.mainbutton android:id="@+id/btn1" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_margin="1dp" android:layout_weight="5" /> <it.helian.violazioni.fe.ui.mainbutton android:id="@+id/btn2" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_margin="1dp" android:layout_weight="5" /> </linearlayout> <linearlayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="10" />

if need farther details, write them down, seek help much possible!

thank in advance

regards,

luca

android exception view actionbarsherlock layout-inflater

No comments:

Post a Comment