我在指纹演示中有一些错误

时间:2016-01-04 06:41:08

标签: android

我正在尝试制作指纹演示。但是,发生了以下异常。我点击了按钮<{1}}

NullPointerException

我的代码如下:

01-04 11:35:18.647 3295-3295/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.letsnurture.fingerprint, PID: 3295
java.lang.NullPointerException: Attempt to invoke virtual method 'void javax.crypto.Cipher.init(int, java.security.Key)' on a null object reference
  at com.letsnurture.fingerprint.MainActivity.initCipher(MainActivity.java:179)
  at com.letsnurture.fingerprint.MainActivity.access$000(MainActivity.java:45)
  at com.letsnurture.fingerprint.MainActivity$1.onClick(MainActivity.java:131)
  at android.view.View.performClick(View.java:5198)
  at android.view.View$PerformClick.run(View.java:21147)
  at android.os.Handler.handleCallback(Handler.java:739)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5417)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

  01-04 12:08:55.382 1836-2383/? E/MDM: [83] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}

1 个答案:

答案 0 :(得分:0)

我尝试了相同的演示,它适用于我。

我认为你应该考虑那些注入注释是否适合你。如果它们不起作用,则必须使用“new”后跟构造函数来自己初始化这些实例。否则你将得到那个空对象引用错误。