android – 构建apk后的错误

android – 构建apk后的错误,第1张

概述生成签名的apk后, *** 作栏视图(共享 *** 作提供程序和searchview)崩溃.当我从 Android工作室调试应用程序时它正在工作,但当我生成签名的apk并安装应用程序到设备我得到这样的错误: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.Search 生成签名的apk后, *** 作栏视图(共享 *** 作提供程序和searchvIEw)崩溃.当我从 Android工作室调试应用程序时它正在工作,但当我生成签名的apk并安装应用程序到设备我得到这样的错误:
java.lang.NullPointerException: Attempt to invoke virtual method 'voID androID.support.v7.Widget.SearchVIEw.setqueryHint(java.lang.CharSequence)' on a null object reference            at tm.veriloft.ertir.ui.SearchActivity.onCreateOptionsMenu(UnkNown Source)            at androID.app.Activity.onCreatePanelMenu(Activity.java:2820)            at androID.support.v4.app.o.onCreatePanelMenu(UnkNown Source)            at androID.support.v7.app.e.a(UnkNown Source)            at androID.support.v7.app.g.a(UnkNown Source)            at androID.support.v7.Widget.as.a(UnkNown Source)            at androID.support.v7.internal.a.a.j(UnkNown Source)            at androID.support.v7.internal.a.b.run(UnkNown Source)            at androID.os.Handler.handleCallback(Handler.java:739)            at androID.os.Handler.dispatchMessage(Handler.java:95)            at androID.os.Looper.loop(Looper.java:135)            at androID.app.ActivityThread.main(ActivityThread.java:5221)            at java.lang.reflect.Method.invoke(Native Method)            at java.lang.reflect.Method.invoke(Method.java:372)            at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)            at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:694)

要么

java.lang.NullPointerException: Attempt to invoke virtual method 'voID androID.support.v7.Widget.ah.a(androID.content.Intent)' on a null object reference            at tm.veriloft.ertir.ui.BlogVIEwActivity.onCreateOptionsMenu(UnkNown Source)            at androID.app.Activity.onCreatePanelMenu(Activity.java:2820)            at androID.support.v4.app.o.onCreatePanelMenu(UnkNown Source)            at androID.support.v7.app.e.a(UnkNown Source)            at androID.support.v7.app.g.a(UnkNown Source)            at androID.support.v7.Widget.as.a(UnkNown Source)            at androID.support.v7.internal.a.a.j(UnkNown Source)            at androID.support.v7.internal.a.b.run(UnkNown Source)            at androID.os.Handler.handleCallback(Handler.java:739)            at androID.os.Handler.dispatchMessage(Handler.java:95)            at androID.os.Looper.loop(Looper.java:135)            at androID.app.ActivityThread.main(ActivityThread.java:5221)            at java.lang.reflect.Method.invoke(Native Method)            at java.lang.reflect.Method.invoke(Method.java:372)            at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)            at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:694)

我正在使用支持库和工具栏的最新版本. (通过设置setSupportActionbar(mToolbar)).

SearchVIEw xml:

<menu xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:ertir="http://schemas.androID.com/apk/res-auto">    <item        androID:ID="@+ID/action_search"        androID:title="@string/Title_activity_search"        ertir:showAsAction="always"        ertir:actionVIEwClass="androID.support.v7.Widget.SearchVIEw" /></menu>

Java的

@OverrIDe    public boolean onCreateOptionsMenu(Menu menu) {        getMenuInflater().inflate(R.menu.search,menu);        MenuItem searchItem = menu.findItem(R.ID.action_search);        mSearchVIEw = (SearchVIEw) searchItem.getActionVIEw();        mSearchVIEw.setqueryHint(getString(R.string.search_hint));        mSearchVIEw.setFocusable(true);        mSearchVIEw.setIconifIEd(false);        mSearchVIEw.requestFocusFromtouch();        mSearchVIEw.setonqueryTextListener(new SearchVIEw.OnqueryTextListener() {            @OverrIDe            public boolean onqueryTextsubmit(String query) {                mSearchVIEw.clearFocus(); //HIDe keyboard                search(query,searchTypeArray.get(searchTypeSpinner.getSelectedItemposition()).getType());                return false;            }            @OverrIDe            public boolean onqueryTextChange(String query) {                if (searchTypeArray.get(searchTypeSpinner.getSelectedItemposition()).getType().equals("blogs"))                    searchAfter(1100,query,searchTypeArray.get(searchTypeSpinner.getSelectedItemposition()).getType());                else                    search(query,searchTypeArray.get(searchTypeSpinner.getSelectedItemposition()).getType());                return false;            }        });        return true;    }

我怎样才能解决这个问题?如上所述,我只有在签署apk后才会收到错误.

解决方法 这是因为您没有适当地配置您的progaurd.在buildTypes和’release’下的build.gradle中,将runProguard更改为true,以runProguard为false并生成已烧录的APK并进行测试.如果它运作良好,请尝试学习适当配置progaurd 总结

以上是内存溢出为你收集整理的android – 构建apk后的错误全部内容,希望文章能够帮你解决android – 构建apk后的错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1138064.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存