java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect

Connected to process 9021 on device friendlyarm__www_arm9_net_-full_android_on_tiny4412-FA4412DBA4120433
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/InstantRun: starting instant run server: is main process
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/art: Rejecting re-init on previously-failed class java.lang.Class
    Rejecting re-init on previously-failed class java.lang.Class
D/OpenGLRenderer: Render dirty regions requested: true
D/Atlas: Validating map...
E/: Device driver API match
    Device driver API version: 401
    User space API version: 401 
    mali: REVISION=Linux-r4p0-00rel0 BUILD_DATE=Fri Jul 18 22:37:22 CST 2014 
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Enabling debug mode 0
W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.app_myapp, PID: 9021
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
        at com.example.app_myapp.MainActivity$MyButtonListener.onClick(MainActivity.java:52)
        at android.view.View.performClick(View.java:4756)
        at android.view.View$PerformClick.run(View.java:19749)
        at android.os.Handler.

--------------------------------------------------

try {
    for (int i=0;i<4;i++)
    {
       // iLedService.ledCtl(i,1);
       ledCtl.invoke(proxy, i, 1);    -------------此行就是52
    }
} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (InvocationTargetException e) {
    e.printStackTrace();
}

-----------------------------------------------------

解决是:将52行的 i改为0,编译烧到开发板,没有问题。

后来:从别的地方复制了一行过来,替换掉了这一行。”ledCtl.invoke(proxy, i, 1);“  居然也没有问题了。之前老是出错,表现为,APP安装正常,只要一点按钮,就崩溃了。

 

 

你可能感兴趣的:(android,studio,3.4)