我正在尝试在我的应用中添加 admob 广告。其他一切工作正常,但是当我添加这个颤振包firebase_admob: ^0.9.0+10时,应用程序在启动时崩溃。
这个包的文档坚持我用以下信息修改元数据部分的AndroidManifest.xml文件,但是当我这样做时,应用程序仍然崩溃:
<!-- Below is the default meta-data and default commenting statement explaining the meta-data section -->
<!-- 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" />
我已经用下面的元数据替换了上面的元数据,因为firebase-admob包文档正在解释。
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544/6300978111"/>
<!-- I'm using sample ad unit id for banner provided here "https://developers.google.com/admob/android/test-ads" -->
以下是我得到的错误:
e: C:\Users\current user\Documents\mobile development\simple_app\android\app\src\main\kotlin\com\example\simple_app\MainActivity.kt: (10, 48): Type mismatch: inferred type is FlutterEngine but PluginRegistry! 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Finished with error: Gradle task assembleDebug failed with exit code 1
我不知道为什么我会收到这个错误。我尝试了不同的方法和类似的 admob 包,但类似的错误不断发生。