簡體   English   中英

錯誤:覆蓋清單:package 在 AndroidManifest.xml:2:5-34 聲明的屬性。 Flutter

[英]Error: Overlay manifest:package atribute declared at AndroidManifest.xml:2:5-34. Flutter

簡單的問題,很難解決(我認為),

當我啟動 main.dart 時出現此錯誤:

Error:
    Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-34 value=(com.example.Scanner)
    has a different value=(com.example.Scanner) declared in main manifest at AndroidManifest.xml:1:70-97
    Suggestion: remove the overlay declaration at AndroidManifest.xml   and place it in the build.gradle:
        flavorName {
            applicationId = "com.example.Scanner"
        }

FAILURE: Build failed with an exception.

這是我的 build.gradle:

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId="com.example.Scanner"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

這是我的 AndroidManifest.xml:

package="com.example.Scanner">

我希望有人能幫助我,否則我不能再在這個應用程序上編程了:(

刪除package="com.example.Scanner"后出現此錯誤:

Launching lib\main.dart on PCT L29 in debug mode...
lib\main.dart:1
√ Built build\app\outputs\flutter-apk\app-debug.apk.
E/AndroidRuntime(18958): FATAL EXCEPTION: main
E/AndroidRuntime(18958): Process: com.example.Scanner, PID: 18958
E/AndroidRuntime(18958): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.Scanner/your_package_name.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "your_package_name.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/lib/arm64, /data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]]
E/AndroidRuntime(18958):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3813)
E/AndroidRuntime(18958):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4074)
E/AndroidRuntime(18958):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
E/AndroidRuntime(18958):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
E/AndroidRuntime(18958):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
E/AndroidRuntime(18958):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
E/AndroidRuntime(18958):    at android.os.Handler.dispatchMessage(Handler.java:110)
E/AndroidRuntime(18958):    at android.os.Looper.loop(Looper.java:219)
E/AndroidRuntime(18958):    at android.app.ActivityThread.main(ActivityThread.java:8347)
E/AndroidRuntime(18958):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18958):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/AndroidRuntime(18958):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
E/AndroidRuntime(18958): Caused by: java.lang.ClassNotFoundException: Didn't find class "your_package_name.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/lib/arm64, /data/app/com.example.Scanner-qq9H2h8k4abCggEZ2-z28Q==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]]
E/AndroidRuntime(18958):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209)
E/AndroidRuntime(18958):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(18958):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(18958):    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
E/AndroidRuntime(18958):    at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:41)
E/AndroidRuntime(18958):    at android.app.Instrumentation.newActivity(Instrumentation.java:1264)
E/AndroidRuntime(18958):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3798)
E/AndroidRuntime(18958):    ... 11 more

Midhun MP [https://stackoverflow.com/users/1104384/midhun-mp] 的工作:

從 androidmanifest 中刪除 package 屬性並檢查

我完成了一個錯誤。 然后我得到一個新的 java 錯誤。 我只將 AndroidManifest.xml 從舊項目復制到新項目,並且它有效。 這對我有用:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.Scanner">
    <!-- 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:name="io.flutter.app.FlutterApplication"
        android:label="Scanner"
        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. -->
            <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>
        <!-- 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>
</manifest>

,但我不知道出了什么問題。 我從來沒有改變過它。 只需更改package="com.example.YOURNAME">android:label="YOURNAME"

我也有同樣的問題,但在完成以下步驟后我明白了我的意思;

您的 package 名稱“com.example.com”(在您的情況下可能不同)在 5 個位置應該相同,例如

1. android/app/src/debug/AndroidManifest.xml

2. android/app/src/main/AndroidManifest.xml

3. android/app/src/profile/AdroidManifest.xml

4. buildgradle文件defaultConfig { applicationId ""}

5.“包”上的MainActivity.javaMainActivity.kotlin

在我的例子中,我的 package 名稱是 com.example.blog_daily。 所以我在所有點重寫了所有同名的包並解決了我的問題。

首先使所有 package 名稱相同//要執行此操作,在終端中顯示的搜索欄中搜索您的 package 名稱並修復它們//然后運行 Z5ACEBC4CB70DDBB074B0AC76AAB176AEDDBB07ZBAC76CB701DDAE7ZBAC76CB701 現在您可以運行 flutter 運行。 我認為它會解決你的問題。

這顯示了存儲的 3 個 Android 文件 - Android Manifest Files

你好,

我遇到了同樣的問題,我在 5 個位置更改了 package 名稱。

1.) android/app/src/debug/AndroidManifest.xml

2.) android/app/src/main/AndroidManifest.xml

3.) android/app/src/profile/AdroidManifest.xml

4.) buildgradle 文件 defaultConfig { applicationId ""}

5.) MainActivity.java on "package" OR MainActivity.kotlin

修改上述文件后,Flutter App運行沒有任何問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM