简体   繁体   中英

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

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.

好的,首先你可以尝试将你的类改为statci - Public class MyClass --> Public static class MyClass或者你可以转到你的eclipse设置然后转到lint首选项然后取消选中它所写的标记,以便在导出时完全检查错误。或者你可以像静态一样解除你的FragmentActivity。但是我建议你不要扩展除了活动之外的任何其他东西,然后实现其余部分并在MainActivity.Hope中声明FragmentActivity这会有所帮助。

Finally i solved error, just added script as below and best regard of Bill.

lintOptions {
abortOnError false}

Under android{

}

Thanks all men who give me answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM