How to disable error like Eclipse when generating signed apk in Android Studio 1
I have problem in my class but when i run it it works well on my mobile using android studio cable, but when i create signed apk i get class error as below
Error:Error: This fragment inner class should be static (app.browser.HomeActivity.MyWebBrowser) [ValidFragment]
I cannot change the static class because when I put the static context of this child class show me the error, so please help me to resolve this issue. I want to disable this error when generating a signed apk. Please, anyone can suggest me.
My code ..
public class HomeActivity extends FragmentActivity implements ActionBar.TabListener {
private ActionBar.Tab iTab;
static String TAB_TITLE="Untitle";
private ViewPager viewPager;
static TabsPageAdapter mAdapter;
static android.app.ActionBar actionBar;
Context context;
Button btNewtab,btCloseTab,btTabCount;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
context=HomeActivity.this;
objectReferences();
createDir();
actionBar =getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.hide();
mAdapter = new TabsPageAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
viewPager.setOffscreenPageLimit(500);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
@Override
public void onPageScrolled(int i, float v, int i2) {
}
@Override
public void onPageSelected(int i) {
// mAdapter.notifyDataSetChanged();
PAGE_CURRENT=i;
System.out.println("CURRENT PAGE DISCRIPTION : "+PAGE_CURRENT);
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
}
// _________________ METHODS FOR IMPLEMENTING THE TABLES __________________________
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
public class TabsPageAdapter extends FragmentStatePagerAdapter {
public TabsPageAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
return new MyWebBrowser();
}
@Override
public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
}
@Override
public int getCount() {
return COUNT_TAB;
}
}
//____________________________________________
//_____________BROWSER CLASS____________________
//____________________________________________
public class MyWebBrowser extends Fragment implements View.OnClickListener,View.OnLongClickListener{
View rootView;
@SuppressLint("AddJavascriptInterface")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.my_web_browser, container, false);
return rootView;
}
}
Look, I'm removing my content for personal reasons, please suggest me this, thanks men
source to share
Ok first you can try changing your class to statci like this, Public class MyClass --> Public static class MyClass
or you can go to eclipse preferences and then select preferences and then turn off the checkboxes where its entry is fully checked for errors on export. Or you can specify your FragmentActivity as static.But I would advise you not to propagate anything other than just the Activity and then implement the rest and declare the FragmentActivity inside your MainActivity.Hope this helps.
source to share