我的Android应用程序在未签名时工作正常。但是当我打开我的应用程序时,它显示出Null Pointer Exception。
我尝试通过“Android Studio”和“assembleRelase”创建签名的apk。但两者都面临同样的例外。
密钥库文件,凭据,别名所有内容都是正确的。但无法找出问题所在?
使用签名的apk获取以下异常 -
public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
ArrayList<Integer> list = new ArrayList<>();
System.out.print("How many integers you will enter: ");
int howMany = scan.nextInt();
double sum = 0;
int number;
for(int i = 0; i < howMany; i++)
{
System.out.println("Enter " + (i+1) + ". number: ");
number = scan.nextInt();
list.add(number);
sum += list.get(i);
}
System.out.println("Sum is : " + sum);
for(int numbers : list)
{
System.out.println("Number is " + numbers + " which is " + (numbers/sum) + " of the sum");
}
}
我的gradle文件如下 -
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.SearchView.setSearchableInfo(android.app.SearchableInfo)' on a null object reference
at com.example.pck.MyActivity.onCreateOptionsMenu(Unknown Source)
at android.app.Activity.onCreatePanelMenu(Activity.java:2820)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.view.k.onCreatePanelMenu(Unknown Source)
at android.support.v7.app.ai.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.view.k.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.a.d.f(Unknown Source)
at android.support.v7.internal.a.e.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:5254)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
}
有人可以建议我,问题是什么?
提前致谢!