Skip to content

خطای Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected❓ [ERROR]:  #36

@AbbasHoseini

Description

@AbbasHoseini

شرح خطا
هنگام ران گرفتن برنامه، خطا میدهد. تمامی نکات گفته شده در داکیومنت ذکر شده؛ موارد اعمال شده به صورت زیر است:
MyApp.kt فایل

`package com.example.pushe_test; // در اینجا پکیج‌نیم برنامه باید قرار داده شود

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant
import co.pushe.plus.flutter.PusheFlutterPlugin
import androidx.multidex.MultiDex

class MyApp : FlutterApplication(), PluginRegistrantCallback {

override fun attachBaseContext(base: Context) {
    super.attachBaseContext(base)
    MultiDex.install(this)
}

override fun onCreate() {
  super.onCreate()

  // other codes

}

override fun registerWith(registry: PluginRegistry) {
  GeneratedPluginRegistrant.registerWith(registry) // Only Embedded v1
}

}`

صفحه ی build.gradle
`` defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.pushe_test" minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true }

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.multidex:multidex:2.0.1"
}
``

فایل AndroidManifest.xml:
`
    <!-- For pushe service -->
    <meta-data
        android:name="pushe_token"
        android:value="bGQ4M2pwNGxxOHo1dmt5ZUBmenlAMTkxNTE2MzY2ODk0" />



    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>
`
فایل pushpec.yaml
`dependencies: flutter: sdk: flutter # Add Pushe pushe_flutter: ^2.6.0`
[//]: # (در صورتی که نصب شما ثبت نمی‌شود لطفا خطاهای مستندات را مطالعه کنید) [//]: # (برای اضافه‌کردن کد آن را از بلاک div خارج کنید تا سمت راست قرار نگیرد)

لاگ خطا
لاگی که در لاگ‌کت هنگام رخ‌دادن خطا چاپ می‌شود. متن کامل استک‌تریس را چاپ کنید.

Launching lib\main.dart on LG M400 in debug mode...
lib\main.dart:1
Note: C:\Users\Seyed Hasan\Desktop\flutter\.pub-cache\hosted\pub.dartlang.org\pushe_flutter-2.6.1\android\src\main\kotlin\co\pushe\plus\flutter\PusheFlutterApplication.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: D:\AbbasProjects\pushe_test\android\app\src\main\kotlin\com\example\pushe_test\MyApp.kt: (12, 42): Unresolved reference: Context
e: D:\AbbasProjects\pushe_test\android\app\src\main\kotlin\com\example\pushe_test\MyApp.kt: (25, 46): Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


اطلاعات محیط تست

  • نسخه‌ی پوشه یا پلاگین 2.6.0
  • نسخه‌ی فریم‌ورک : 2.10.3
  • سیستم عامل اندروید

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions