从Android v1迁移到V2

4

大家好,我对Flutter还是新手,遇到了这个问题:

我的应用显然是V2版本,但是Android Studio仍提示需要迁移应用。

我按照建议执行了相应步骤,但结果依旧如此。 有谁可以告诉我我做错了什么吗? 以下链接介绍了我需要做的内容: 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>

文件 MainActivity.kt 包含以下内容:

 package com.example.ipill

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

我尝试使用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

你从哪里得到那个消息的?你能展示一下你的日志吗? - Mariano Zorrilla
我刚刚更新了帖子,加上了错误信息。 - Alex97
日志中没有提到这一点,但是它显示了尝试获取 ${ipill} 的错误...你从哪里获取这个变量的? - Mariano Zorrilla
在 GitHub 上我刚刚发布的链接中写道要使用 &{applicationName},所以我就这样做了。 - Alex97
文档中写的是"${applicationName}"而不是"${ipill}"...你不必指定你的应用程序的实际名称,"applicationName"是一个实际的变量,它将自动填充。 - Mariano Zorrilla
2个回答

12

我可以通过在 android/app/src/main/AndroidManifest.xml 中将 android:name 设置为 android:name="${applicationName}" 来解决这个问题。

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


1
对于那些不确定在<manifest>标签内的<application>标签中android:name是哪一个的人。 - Renato Cron

6

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接