pusheco / pushe-flutter

Pushe plugin for Flutter framework
Other
14 stars 4 forks source link

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

Open AbbasHoseini opened 2 years ago

AbbasHoseini commented 2 years ago
[//]: # ([ERROR] و اموجی در تیتر برای وضوح مشکل ترجیحا باقی بماند) [//]: # (لطفا حتما تمپلیت را رعایت کنید تا مشکل به خوبی توضیح داده شود و متون تمپلیت را پاک نکنید) **شرح خطا** هنگام ران گرفتن برنامه، خطا میدهد. تمامی نکات گفته شده در داکیومنت ذکر شده؛ موارد اعمال شده به صورت زیر است: 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:

`<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.pushe_test"> <application android:label="pushe_test" android:name=".MyApp" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">

        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <!-- 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 - سیستم عامل اندروید
mahdi-malv commented 2 years ago

Duplicate of #35 لطفا ۲.۶.۱ رو تست کنید ببینید حل میشه

AbbasHoseini commented 2 years ago

Duplicate of #35 لطفا ۲.۶.۱ رو تست کنید ببینید حل میشه

متاسفانه مشکل هنوز حل نشده. همون ارور

mahdi-malv commented 1 year ago

سلام @AbbasHoseini عذرخواهی بابت تاخیر

تیتر ایشو باید حل بشه و توی ایشوهای مرتبط تایید هم گرفته شده اما در بعضی جاهای دیگه از لاگ Unresolved reference هست از یه کلاس مثل Context فک کنم این مشکل سمت پیاده سازی باشه که درست کلاس ایمپورت نشده. از Android studio برای استفاده کردن بخش جاوای کد به طور مجزا استفاده کنید اونطوری ساختار ماژولار پروژه اندروید رو میبینید. اونطوری میتونید مشکل رو راحتتر متوجه بشید.