2016-11-08 34 views
0

我试图安装Android推送通知是这样的: react-native-push-notification如何在反应原生项目中安装android推送通知?

但是,当我试图建立我的应用程序react-native run-android,我得到这个错误:

BUILD FAILED 

Total time: 2.666 secs 
Could not install the app on the device, read the error above for details. 
Make sure you have an Android emulator running or a device connected and have 
set up your Android development environment: 
https://facebook.github.io/react-native/docs/android-setup.html 


D:\react\react-WriteNow>run 
JS server already running. 
Running C:\Program Files (x86)\Android\android-sdk/platform-tools/adb -s ce051605a9626a3304 reverse tcp:8081 tcp:8081 
Building and installing the app on the device (cd android && gradlew.bat installDebug... 
please apply google-services plugin at the bottom of the build file. 
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used. 
please apply google-services plugin at the bottom of the build file. 

FAILURE: Build failed with an exception. 

* What went wrong: 
A problem occurred configuring root project 'WriteNow'. 
> java.lang.NullPointerException (no error message) 

我的文件: 的Android /应用/build.gradle

dependencies { 
    // compile ('com.google.android.gms:play-services-gcm:9.0.0') { 
    //  force = true; 
    // } 

    compile fileTree(dir: "libs", include: ["*.jar"]) 
    compile "com.android.support:appcompat-v7:23.0.1" 
    compile "com.facebook.react:react-native:+" // From node_modules 
     compile "com.facebook.android:facebook-android-sdk:4.8.+" 
    compile "com.android.support:support-v13:23+" 
    compile ('com.google.android.gms:play-services-gcm:8.4.0') { 
     force = true; 
    } 
    compile project(':react-native-push-notification') 
    compile project(':react-native-sqlite-storage') 
    compile project(':react-native-image-picker') 
    compile project(':react-native-vector-icons') 
    compile project(':react-native-contacts') 


} 
apply plugin: "com.google.gms.google-services" 

的Android/settings.gradle

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 

    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     mavenLocal() 
     jcenter() 
     maven { 
      url "$rootDir/../node_modules/react-native/android" 
     } 
    } 
} 
apply plugin: "com.google.gms.google-services" 

enter image description here

任何想法,为什么它不工作?

回答

0

此命令解决该问题:

android update sdk -u -a -t