gpt4 book ai didi

android - Firebase 函数未解析(无法解析 "FirebaseInstanceIdService")

转载 作者:行者123 更新时间:2023-11-30 00:14:30 25 4
gpt4 key购买 nike

因此,我正在尝试为我的应用程序使用 Firebase 云消息传递,但是当我尝试对其进行测试时,即使是示例代码也会向我抛出错误。

public class FirebaseIDService extends FirebaseInstanceIdService {
private static final String TAG = "FirebaseIDService";

@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);

// TODO: Implement this method to send any registration to your app's servers.
sendRegistrationToServer(refreshedToken);
}

/**
* Persist token to third-party servers.
*
* Modify this method to associate the user's FCM InstanceID token with any server-side account
* maintained by your application.
*
* @param token The new token.
*/
private void sendRegistrationToServer(String token) {
// Add custom implementation, as needed.
}
}

未找到任何引用 Firebase API 的函数,就好像我还没有包含它一样。这是我的应用程序 gradle:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

这是我的项目 gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

最佳答案

试试这个:

ionic cordova platforms remove android
ionic cordova plugin remove cordova-plugin-firebase
ionic cordova platforms add android

关于android - Firebase 函数未解析(无法解析 "FirebaseInstanceIdService"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47522337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com