简体   繁体   English

我正在尝试在我的 flutter 项目中使用“google_mobile_ads”,但我正在将其迁移到嵌入 v2 的 Android

[英]I am trying to use “google_mobile_ads” in my flutter project but I am getting this migrated to the Android embedding v2

The plugin google_mobile_ads requires your app to be migrated to the Android embedding v2.插件google_mobile_ads要求您的应用迁移到 Android 嵌入 v2。 Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command.按照https://flutter.dev/go/android-project-migration上的步骤重新运行此命令。

So I tried following the steps but I couldn't found the "MainActivity.java" in my project anyWhere and couldn't follow along所以我尝试按照这些步骤操作,但在我的项目中任何地方都找不到“MainActivity.java”,也无法继续

MyProject tree我的项目树

migration error迁移错误

https://flutter.dev/go/android-project-migration this the Link Which it is suggesting to follow https://flutter.dev/go/android-project-migration这是建议遵循的链接

just open this files in your project and copy >> paste this lines of code and it will work.......make sure to delete all lines of code in your this files and replace it to this new ones.只需在您的项目中打开这些文件并复制>>粘贴这行代码,它就会起作用.......确保删除此文件中的所有代码行并将其替换为新的代码行。

1: MainActivity.java 1:MainActivity.java


package co.appbrewery.flash_chat;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {
  
}

2: styles.xml 2:styles.xml


<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>

3: AndroidManifest.xml 3:AndroidManifest.xml


<manifest xmlns:android="http://schemas.android.com/apk/res/android"   
          package="co.appbrewery.flash_chat">  
<!-- 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. -->
<application android:label="flash_chat" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" 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.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <meta-data android:name="flutterEmbedding" android:value="2" />
</application>
</manifest>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在 flutter android 项目中收到 gradle 错误? - Why I am getting gradle error in flutter android project? 为什么我在 Android Studio 的 Flutter 项目中的 build.gradle 中出现此错误? - Why am I getting this error in build.gradle in my Flutter Project in Android Studio? 尝试在我的 Android 应用程序项目中添加电话身份验证时出现错误 - I am getting error when trying to add phone authentication in my Android app project 我正在使用firebase_admob在我的flutter应用中实施广告,但广告在发布版本apk中不起作用 - I am using firebase_admob to implement ads in my flutter app, but ads are not working in release build apk 我正在尝试在 flutter 中使用 Date Picker 并将我的日期存储到 cloud firestore 中。但是我的日期显示为空 - I am trying to use Date Picker in flutter and store my date into cloud firestore .But my date is showing as null Flutter:尝试启动时收到过时的消息 - Flutter: I am getting an outdated message when trying to launch 我没有收到 FCM 注册令牌。 我试图在凌空依赖的帮助下在我的 api 上发布 android id 和 token - I am not getting FCM Registration token. I am trying to post android id and token on my api with the help of volley dependency 我正在尝试从我的 flutter 移动应用程序中调用 firebase 云功能。 我可以从 firebase 函数调用那些:shell 或本地 - I am trying to call firebase cloud functions from my flutter mobile application. I am able to call those from firebase functions : shell or locally 我正在使用 flutter 编写 Firebase 应用程序,但我收到有关 google-services.json 和初始化的错误 - I am coding a Firebase app with flutter but i am getting errors about google-services.json and inititilization 当我按照文档尝试将我的 Android Studio 连接到 Firebase 时出现错误 - Getting error when I am trying to connect my Android Studio to Firebase following the docs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM