Flutter + Android:如何从项目“ E / FirebaseInstanceId:无法解析目标意图服务”中删除firebase

时间:2019-01-29 05:21:59

标签: android firebase flutter

我在flutter项目的旧版本中使用了Firebase,但我想我要么没有正确删除它,要么一直在删除它。无论如何,我如何摆脱Firebase并因此从我的Android日志中删除此错误?我已经抓了整个项目,找不到Firebase的1个实例。不久前,我已从yaml文件中将其删除,但仍会弹出。

  

FirebaseInstanceId:无法解析目标意图服务,正在跳过   类别名称强制FirebaseInstanceId:传送   消息:找不到ServiceIntent。

这是我的AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.eumag">
    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here.
         android:name="io.flutter.app.FlutterApplication"

         -->

    <application
        android:name=".ServiceChannel"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        android:label="eumag">
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
                <data
                    android:host="www.example.com"
                    android:pathPrefix="/eumag"
                    android:scheme="http" />
                <!-- note that the leading "/" is required for pathPrefix-->
                <!-- Accepts URIs that begin with "example://gizmos” -->
                <data
                    android:host="eumag"
                    android:scheme="example" />
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.spotify.sdk.android.authentication.LoginActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <service
            android:name=".ForegroundService"
            android:stopWithTask="false">
        </service>
    </application>
</manifest>

我的应用程序的gradle文件

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.eumag"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(':spotify-app-remote')
    implementation 'com.android.support:support-compat:'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation "com.google.code.gson:gson:2.8.5"
//    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
//    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
    implementation 'com.spotify.android:auth:1.1.0'
    implementation ('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
}

和我的项目gradle文件

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" }

    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

1 个答案:

答案 0 :(得分:0)

  1. 转到您的pubscpec并删除所有Firebase软件包
  2. 转到您的Gradle文件,根目录和应用程序级别,然后删除Firebase引用
  3. 转到Flutter项目的根目录,删除构建文件夹
  4. 转到您的Android项目,删除其构建文件夹
  5. 在整个项目中搜索FirebaseInstanceId(如果您使用的是Visual Studio代码)。

在构建项目时,Flutter Firebase软件包将生成FirebaseInstanceId和接收器。在这种情况下,除非您添加自己的一个。只需删除该文件即可。