【发布时间】:2018-01-23 21:19:49
【问题描述】:
在安装 react-native-fcm 后,我正在使用 react native 构建一个分离的 android 应用程序,但总是收到以下错误消息:
我的项目 gradle 如下所示:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// Point to local maven repository
url "$rootDir/../.expo-source/android/maven"
}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
虽然我的 app/build.gradle 看起来像:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "fi.x.y"
minSdkVersion 19
targetSdkVersion 26
versionCode 2
versionName "1.0.2"
multiDexEnabled true
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
manifestPlaceholders = [
'appAuthRedirectScheme': 'fi.x.y'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "8g"
}
lintOptions {
abortOnError false
}
}
task exponentPrebuildStep(type: Exec) {
workingDir '../../'
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
} else {
commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
}
}
preBuild.dependsOn exponentPrebuildStep
repositories{
flatDir{
dirs "../../node_modules/react-native-background-geolocation/android/libs"
}
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-vector-icons')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.android.gms:play-services:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.google.android.gms:play-services-places:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile('host.exp.exponent:expoview:22.0.0@aar') {
exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
exclude group: 'com.facebook.android', module: 'audience-network-sdk'
exclude group: 'io.nlopez.smartlocation', module: 'library'
transitive = true
}
compile ('com.facebook.android:facebook-android-sdk:4.+')
compile('com.facebook.android:audience-network-sdk:4.+') {
exclude module: 'play-services-ads'
}
compile('io.nlopez.smartlocation:library:3.2.11') {
transitive = false
}
compile(project(':react-native-background-geolocation')) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
compile(name: 'tslocationmanager', ext: 'aar') {
exclude group: 'com.google.android.gms'
}
compile project(':react-native-fcm')
compile 'com.google.firebase:firebase-core:11.8.0' //this decides your firebase SDK version
}
apply plugin: 'com.google.gms.google-services'
主要应用:
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Add your own packages here!
// TODO: add cool native modules
new RNBackgroundGeolocation(),
// Needed for `react-native link`
// new MainReactPackage(),
new RNFirebasePackage(),
new VectorIconsPackage(),
new RNFirebaseMessagingPackage(),
new FIRMessagingPackage()
);
}
我正在点击此链接为 react native android 安装推送通知:https://github.com/evollu/react-native-fcm
我没有看到任何日志进入控制台日志,项目正在成功构建,但是当启动应用程序时出现带有错误消息的白屏 Package is not running at xxx:yy。
我之前没有这个问题,因为安装fcm库时出现冲突,我也不得不将所有google服务包都更改为11.8.0!
知道它会导致什么导致我无法打开我的应用程序!
【问题讨论】:
标签: javascript android reactjs react-native firebase-cloud-messaging