Qutbuddin Bohra Qutbuddin Bohra - 2 months ago 10
Android Question

How to disable error like Eclipse while creating signed apk in Android Studio 1

I have problem in my Class, but when I run it its running good on my mobile using cable to android studio, but when I generate signed apk then I get class error like below

Error:Error: This fragment inner class should be static (app.browser.HomeActivity.MyWebBrowser) [ValidFragment]


I can't change class static because when I put static this child class context show me error, so please help me bout this question I want to disable this error when I generate 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) {

}
});




}


//_________________TABS IMPLEMENTS METHODS__________________________

@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;
}


}

Hear i remove my content for personal reason please suggest me about this, Thanks men

Answer

I think you should try to add following script in you build.gradle. (Must write in android{} tag)

lintOptions {
    abortOnError false
}

When your release build generate an error by lint, the build task will not abort.