【问题标题】:react native Push Notification error: Cannot invoke method get() on null object反应本机推送通知错误:无法在空对象上调用方法 get()
【发布时间】:2018-07-18 20:07:35
【问题描述】:

我使用 npm 模块https://github.com/zo0r/react-native-push-notification

我执行了自述文件中的步骤。 我只想将推送通知从我的后端发送到应用程序。所以我正在使用 Firebase 云消息传递。或者这不是一个好主意? 我在那里注册了我的应用程序,我不得不将这些代码粘贴到构建 gradle 文件中。

(<project>/build.gradle):
buildscript {
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:4.0.0'
  }
}
(<project>/<app-module>/build.gradle):
dependencies {
  // Add this line
  compile 'com.google.firebase:firebase-core:16.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

执行这些步骤后,我收到错误:“无法在 null 对象上调用方法 get()”,当使用 react native 运行此应用程序时。

我尝试使用 android studio 打开项目,但出现相同的错误消息。有人可以帮我吗?

【问题讨论】:

    标签: javascript android reactjs react-native push-notification


    【解决方案1】:

    您可以通过将com.android.tools.build:gradle 升级到3.1.0 来避免该错误

    您可以通过以下方式做到这一点:

    // project/build.gradle
    
    buildscript {
      dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0' // <- Here
    
        classpath 'com.google.gms:google-services:4.0.0'
      }
    }
    

    现在您的项目应该可以正常同步了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      相关资源
      最近更新 更多