编程语言
首页 > 编程语言> > java-如何在Android Studio 1中创建签名的apk时禁用Eclipse之类的错误

java-如何在Android Studio 1中创建签名的apk时禁用Eclipse之类的错误

作者:互联网

我的班上有问题,但是当我使用连接到android studio的电缆运行它时,它在我的手机上运行良好,但是当我生成签名的apk时,我得到了如下的班级错误

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

我无法更改静态类,因为当我将其置于静态状态时,此子类上下文向我显示错误,因此请帮助我解决此问题,我想在生成带符号的apk时禁用此错误.请任何人都可以建议我.

我的代码

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) {

        }
    });




}

// _________________标签实施方法__________________________

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

}

听到我出于个人原因删除了我的内容,请向我提出建议,谢谢

解决方法:

我认为您应该尝试在build.gradle中添加以下脚本. (必须使用android {}标签编写)

lintOptions {
    abortOnError false
}

当您的发行版构建通过lint生成错误时,构建任务将不会中止.

标签:android-gradle,android-studio,eclipse,java,android
来源: https://codeday.me/bug/20191028/1955408.html