编译项目(路径:':backend',配置:'android-endpoints')错误

时间:2015-07-11 19:52:38

标签: java android android-studio

添加模块Google云消息后出现问题。 我给这个错误的人。

07-12 02:07:07.937  23773-23773/? D/dalvikvm﹕ Late-enabling CheckJNI
07-12 02:07:08.037  23773-23773/com.example.debayan.usingimageview D/dalvikvm﹕ GC_FOR_ALLOC freed 108K, 36% free 14480K/22584K, paused 17ms, total 17ms
07-12 02:07:08.137  23773-23773/com.example.debayan.usingimageview I/dalvikvm-heap﹕ Grow heap (frag case) to 66.234MB for 52515856-byte allocation
07-12 02:07:08.517  23773-23773/com.example.debayan.usingimageview D/AndroidRuntime﹕ Shutting down VM
07-12 02:07:08.517  23773-23773/com.example.debayan.usingimageview W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417bfd58)
07-12 02:07:08.527  23773-23773/com.example.debayan.usingimageview E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.debayan.usingimageview, PID: 23773
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debayan.usingimageview/com.example.debayan.usingimageview.MainActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2247)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5050)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.example.debayan.usingimageview.MainActivity.onCreate(MainActivity.java:20)
            at android.app.Activity.performCreate(Activity.java:5248)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2247)
            at android.app.ActivityThread.access$800(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5050)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
            at dalvik.system.NativeStart.main(Native Method)

删除

  

编译项目(路径':后端'配置'android-endpoints')

一切都很完美。

我该怎么办?

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

在我的情况下,我实现了这两个依赖项:

编译'com.google.android.gms:play-services:8.4.0'

编译项目(路径:':backend',配置:'android-endpoints')

以某种方式将这两者加在一起会导致问题,我不知道为什么。无论如何,我添加了第一个依赖项,以便我可以添加广告。我用它代替:

'com.google.android.gms:发挥服务的广告:8.4.0'

问题已经消失