从 Android v1 迁移到 V2

Ale*_*x97 4 android android-manifest flutter

大家好,我是 Flutter 的新手,我遇到了这个问题。

我的应用程序显然是 V2,但 Android 工作室仍然表示该应用程序必须迁移。

我执行了他们建议的步骤,但仍然得到相同的结果有人可以建议我做错了什么吗?这是我必须做的事情的链接: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

这是我修改的。

AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ipill">
    <!-- 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. -->

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.androidtutorialpoint.mymapsappsdirection.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <application
        android:name="${ipill}"
        android:label="ipill"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme"

                />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <!-- Specify that the launch screen should continue being displayed -->
            <!-- until Flutter renders its first frame. -->

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- 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" />
        <meta-data
            android:name="com.google.android.gms.wallet.api.enabled"
            android:value="true" />
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value=""/>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

文件 MainActivity.kt 包含以下内容

 package com.example.ipill

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}
Run Code Online (Sandbox Code Playgroud)

我还尝试使用 flutter install --ignore-deprecation 标志,但他们说它不起作用。

任何帮助,因为我迷路了,我真的需要让应用程序工作,我发现了一个类似的问题,我应用了他们的建议,但它不起作用。

这是我得到的日志

    FAILURE: Build failed with an exception.
    D:\7_GitHub\Piller2.0\android\app\src\main\AndroidManifest.xml:18:9-32 Error:
    Attribute application@name at AndroidManifest.xml:18:9-32 requires a placeholder substitution but no value for <ipill> is provided.
D:\7_GitHub\Piller2.0\android\app\src\debug\AndroidManifest.xml Error:
    Validation failed, exiting
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* 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 12s
Exception: Gradle task assembleDebug failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

jon*_*jon 12

我能够通过设置来解决这个android:name问题

android:name="${applicationName}"android/app/src/main/AndroidManifest.xml

显然,即使你已经升级到 V2 嵌入,Flutter 2.10 的检查也比以前的版本更严格。


小智 6

在你的 main/xml 文件中,更改android:nameandroid:name="${applicationName}

官方文档可以参考https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects