【问题标题】:Onesignal errors in flutter: requires a placeholder substitution but no value for颤振中的单信号错误:需要占位符替换,但没有值
【发布时间】:2021-03-14 15:36:16
【问题描述】:

构建 APK (Flutter) 时出现以下错误。

我添加了我的 Onesignal 应用程序 ID,即使你目前没有使用它。 有人提到我的Onesignal SDK没有正确安装:https://documentation.onesignal.com/docs/flutter-sdk-setup 但我不认为就是这样。

Fluxstore 应用

谢谢!

C:\fluxstore\build\app\intermediates\merged_manifest\release\out\AndroidManifest.xml:328:13-48 Error:
        Attribute meta-data#onesignal_app_id@value at AndroidManifest.xml:328:13-48 requires a placeholder substitution but no value for <onesignal_app_id> is provided.
C:\fluxstore\build\app\intermediates\merged_manifest\release\out\AndroidManifest.xml:331:13-67 Error:
        Attribute meta-data#onesignal_google_project_number@value at AndroidManifest.xml:331:13-67 requires a placeholder substitution but no value for <onesignal_google_project_number> is provided.
C:\fluxstore\build\app\intermediates\merged_manifest\release\out\AndroidManifest.xml Error:
        Validation failed, exiting

这是我的 Android 清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.website.store">
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
    <!-- 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="Website"
        android:icon="@mipmap/launcher_icon">

        <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>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data
                android:name="default-url"
                android:value="https://website.co.za" />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="https"
                    android:host="website.co.za" />
                <data  android:scheme="http" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />

         <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/logo" />
        <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
            notification message. See README(https://googl/6BKBk7) for more. -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/notiColor" />

        <!-- Google map and Admod setup -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/api_key"/>
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="@string/admob_api"/>

        <!-- Facebook Login configuration -->
        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:exported="true"
            />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </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>

【问题讨论】:

    标签: android flutter-dependencies


    【解决方案1】:

    这可能会有所帮助...

    试着去你的

    android/app/build.gradle

    找到defaultConfig并添加以下代码:

    manifestPlaceholders = [
                onesignal_app_id: 'ONE SIGNAL APP ID',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
    
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.app.android"
        ...
        manifestPlaceholders = [
            onesignal_app_id: 'ONE SIGNAL APP ID HERE',
            // Project number pulled from dashboard, local value is ignored.
            onesignal_google_project_number: 'REMOTE'
        ]
    }
    

    您的 Onesignal Google 项目编号是您的 Firebase Sender ID。

    【讨论】:

      【解决方案2】:

      你可以使用类似下面的东西

      android {
      defaultConfig {
          manifestPlaceholders = [hostName:"www.example.com"]
      }
      ...
      

      }

      然后,您可以将其中一个占位符作为属性值插入清单文件,如下所示:

      <intent-filter ... >
          <data android:scheme="https" android:host="${hostName}" ... />
          ...
      </intent-filter>
      

      欲了解更多信息:https://developer.android.com/studio/build/manage-manifests#groovy

      【讨论】:

        猜你喜欢
        • 2023-02-04
        • 2016-09-18
        • 2019-02-10
        • 1970-01-01
        • 1970-01-01
        • 2022-01-01
        • 2017-12-18
        • 2020-02-01
        • 1970-01-01
        相关资源
        最近更新 更多