AndroidManifest.xml 结构不正确
AndroidManifest.xml structured incorrectly
2021 年 10 月 22 日更新
- 我的调试 AndroidManifest.xml 文件在构建时出现错误。
- 仅在 Android 模拟器中出现,IOS 运行完美。
- android.useAndroidX=真
- android.enableJetifier=真
摘要:
错误是由标签引起的:
com.yalantis.ucrop.UCropActivity 这是不合适的。即使我把它移到正确的地方,它在建造时会自动移回。
我得到的错误:
error: unexpected element <activity> found in <manifest>.
这是我的 debug/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tomasward.fredi"
android:versionCode="1"
android:versionName="1.0.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 适配Android R包可见性 开始 -->
<queries package="com.tomasward.fredi" >
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.media.action.ACTION_VIDEO_CAPTURE" />
</intent>
<!-- For browser content -->
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent> <!-- End of browser content -->
<!-- For CustomTabsService -->
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
<application
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:icon="@mipmap/ic_launcher"
android:label="Fredi"
android:supportsRtl="true" >
<activity
android:name="com.tomasward.fredi.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize" >
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD9pKRFa-bPpig6wnQC5kj7nNMFF72rN3U" />
<meta-data
android:name="com.google.android.gms.ads.ca-app-pub-2176711646772763~2658546918"
android:value="ca-app-pub-2176711646772763~2658546918" />
<!--
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" />
<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:theme="@style/com_facebook_activity_theme" />
<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>
<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:host="cct.com.tomasward.fredi"
android:scheme="fbconnect" />
</intent-filter>
</activity>
<!-- Set up the Sign in with Apple activity, such that it's callable from the browser-redirect -->
<activity
android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
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="signinwithapple" />
<data android:path="callback" />
</intent-filter>
</activity>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:directBootAware="true"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.database.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.auth.FlutterFirebaseAuthRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.storage.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.core.FlutterFirebaseCoreRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<provider
android:name="io.flutter.plugins.imagepicker.ImagePickerFileProvider"
android:authorities="com.tomasward.fredi.flutter.image_provider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/flutter_image_picker_file_paths" />
</provider>
<meta-data
android:name="io.flutter.embedded_views_preview"
android:value="true" />
<activity android:name="com.facebook.CustomTabMainActivity" />
<provider
android:name="com.facebook.internal.FacebookInitProvider"
android:authorities="com.tomasward.fredi.FacebookInitProvider"
android:exported="false" />
<receiver
android:name="com.facebook.CurrentAccessTokenExpirationBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.facebook.sdk.ACTION_CURRENT_ACCESS_TOKEN_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name="com.google.firebase.auth.internal.GenericIdpActivity"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<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:host="firebase.auth"
android:path="/"
android:scheme="genericidp" />
</intent-filter>
</activity>
<activity
android:name="com.google.firebase.auth.internal.RecaptchaActivity"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<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:host="firebase.auth"
android:path="/"
android:scheme="recaptcha" />
</intent-filter>
</activity>
<service
android:name="com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.auth.api.gms.service.START" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.tomasward.fredi.firebaseinitprovider"
android:directBootAware="true"
android:exported="false"
android:initOrder="100" />
<provider
android:name="com.luck.picture.lib.PictureFileProvider"
android:authorities="com.tomasward.fredi.luckProvider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name="com.luck.picture.lib.PictureSelectorActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorWeChatStyleActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorCameraEmptyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Picture.Theme.Translucent" />
<activity
android:name="com.luck.picture.lib.PictureCustomCameraActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PicturePreviewActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorPreviewWeChatStyleActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureVideoPlayActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="sensor" />
<activity
android:name="com.luck.picture.lib.PictureExternalPreviewActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PicturePlayAudioActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Base.Theme.NoActionBar" />
<activity
android:name="com.yalantis.ucrop.PictureMultiCuttingActivity"
android:theme="@style/Base.Theme.NoActionBar" />
<activity
android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
android:excludeFromRecents="true"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<service
android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
android:exported="true"
android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" /> <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:exported="false"
android:theme="@android:style/Theme.Translucent" />
<provider
android:name="com.google.android.gms.ads.MobileAdsInitProvider"
android:authorities="com.tomasward.fredi.mobileadsinitprovider"
android:exported="false"
android:initOrder="100" />
<service
android:name="com.google.android.gms.ads.AdService"
android:enabled="true"
android:exported="false" />
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="com.tomasward.fredi.workmanager-init"
android:directBootAware="false"
android:exported="false"
android:multiprocess="true" />
<service
android:name="androidx.work.impl.background.systemalarm.SystemAlarmService"
android:directBootAware="false"
android:enabled="@bool/enable_system_alarm_service_default"
android:exported="false" />
<service
android:name="androidx.work.impl.background.systemjob.SystemJobService"
android:directBootAware="false"
android:enabled="@bool/enable_system_job_service_default"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name="androidx.work.impl.utils.ForceStopRunnable$BroadcastReceiver"
android:directBootAware="false"
android:enabled="true"
android:exported="false" />
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$BatteryChargingProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$BatteryNotLowProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BATTERY_OKAY" />
<action android:name="android.intent.action.BATTERY_LOW" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$StorageNotLowProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
<action android:name="android.intent.action.DEVICE_STORAGE_OK" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.RescheduleReceiver"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.TIME_SET" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxyUpdateReceiver"
android:directBootAware="false"
android:enabled="@bool/enable_system_alarm_service_default"
android:exported="false" >
<intent-filter>
<action android:name="androidx.work.impl.background.systemalarm.UpdateProxies" />
</intent-filter>
</receiver>
<service
android:name="androidx.room.MultiInstanceInvalidationService"
android:exported="false" />
<activity
android:name="com.twitter.sdk.android.core.identity.OAuthActivity"
android:configChanges="orientation|screenSize"
android:excludeFromRecents="true"
android:exported="false" />
</application>
</manifest>
根据要求,这里是 GeneratedPluginRegistrant.java 代码:
@Keep
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
try {
dev.gilder.tom.apple_sign_in.AppleSignInPlugin.registerWith(shimPluginRegistry.registrarFor("dev.gilder.tom.apple_sign_in.AppleSignInPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin apple_sign_in, dev.gilder.tom.apple_sign_in.AppleSignInPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.auth.FlutterFirebaseAuthPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_auth, io.flutter.plugins.firebase.auth.FlutterFirebaseAuthPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_core, io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.database.FirebaseDatabasePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_database, io.flutter.plugins.firebase.database.FirebaseDatabasePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_storage, io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin", e);
}
try {
flutterEngine.getPlugins().add(new ru.innim.flutter_login_facebook.FlutterLoginFacebookPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_login_facebook, ru.innim.flutter_login_facebook.FlutterLoginFacebookPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e);
}
try {
com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin.registerWith(shimPluginRegistry.registrarFor("com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_twitter_login, com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin", e);
}
try {
flutter.plugins.vibrate.VibratePlugin.registerWith(shimPluginRegistry.registrarFor("flutter.plugins.vibrate.VibratePlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_vibrate, flutter.plugins.vibrate.VibratePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin google_mobile_ads, io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.googlesignin.GoogleSignInPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin google_sign_in, io.flutter.plugins.googlesignin.GoogleSignInPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.ggichure.github.hexcolor.HexcolorPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin hexcolor, com.ggichure.github.hexcolor.HexcolorPlugin", e);
}
try {
flutterEngine.getPlugins().add(new vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin image_cropper, vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin image_picker, io.flutter.plugins.imagepicker.ImagePickerPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.chavesgu.images_picker.ImagesPickerPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin images_picker, com.chavesgu.images_picker.ImagesPickerPlugin", e);
}
try {
com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(shimPluginRegistry.registrarFor("com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin keyboard_visibility, com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin path_provider, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin shared_preferences, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e);
}
}
}
首先,you need to migrate your android project to v2 embedding
(引自https://github.com/hnvn/flutter_image_cropper)。那么你能试试这个吗?
其次,能否请您在您的代码中搜索您使用 com.yalantis.ucrop.UCropActivity
的地方?我想这可能是由某种构建脚本引起的,它会自动将那部分代码注入到您的 xml(但注入错误)。
第三,也许还显示你所有的依赖项。
您似乎有 2 个 activity
标签,名称为 com.yalantis.ucrop.UCropActivity
。
移动
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
进入 application
标签。
删除,
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Base.Theme.NoActionBar" />
实际答案
在一个 flutter 项目中,有三个主要的 Android 清单文件。好像是我想设置Google Ad Mob包的时候不小心插入了
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
在debug/AndroidManifest.xml,当需要进入main/AndroidManifest.xml。这导致了重复和错误。清理和构建错误后,错误消失了,但由于 google ad mob 包的设置不正确,我仍然无法 运行 应用程序。
底线:使用 google_mobile_ads
包时,请正确设置。
我只是对您的 Debug
清单感到困惑。与 Main
清单相比,重复项太多。 Debug
清单扩展了 Main
清单,所以我不确定您为什么有重复的标签。如果您希望这些活动出现在所有构建类型(发布、配置文件、调试)中,您应该将其放在 Main
清单中。
尝试删除 Debug
中的重复项。所有这些都可以在 Main
中,只有特殊权限或其他权限在 Debug
.
中
2021 年 10 月 22 日更新
- 我的调试 AndroidManifest.xml 文件在构建时出现错误。
- 仅在 Android 模拟器中出现,IOS 运行完美。
- android.useAndroidX=真
- android.enableJetifier=真
摘要: 错误是由标签引起的: com.yalantis.ucrop.UCropActivity 这是不合适的。即使我把它移到正确的地方,它在建造时会自动移回。
我得到的错误:
error: unexpected element <activity> found in <manifest>.
这是我的 debug/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tomasward.fredi"
android:versionCode="1"
android:versionName="1.0.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 适配Android R包可见性 开始 -->
<queries package="com.tomasward.fredi" >
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.media.action.ACTION_VIDEO_CAPTURE" />
</intent>
<!-- For browser content -->
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent> <!-- End of browser content -->
<!-- For CustomTabsService -->
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
<application
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:icon="@mipmap/ic_launcher"
android:label="Fredi"
android:supportsRtl="true" >
<activity
android:name="com.tomasward.fredi.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize" >
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD9pKRFa-bPpig6wnQC5kj7nNMFF72rN3U" />
<meta-data
android:name="com.google.android.gms.ads.ca-app-pub-2176711646772763~2658546918"
android:value="ca-app-pub-2176711646772763~2658546918" />
<!--
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" />
<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:theme="@style/com_facebook_activity_theme" />
<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>
<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:host="cct.com.tomasward.fredi"
android:scheme="fbconnect" />
</intent-filter>
</activity>
<!-- Set up the Sign in with Apple activity, such that it's callable from the browser-redirect -->
<activity
android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
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="signinwithapple" />
<data android:path="callback" />
</intent-filter>
</activity>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:directBootAware="true"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.database.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.auth.FlutterFirebaseAuthRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.storage.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:io.flutter.plugins.firebase.core.FlutterFirebaseCoreRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.storage.StorageRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<provider
android:name="io.flutter.plugins.imagepicker.ImagePickerFileProvider"
android:authorities="com.tomasward.fredi.flutter.image_provider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/flutter_image_picker_file_paths" />
</provider>
<meta-data
android:name="io.flutter.embedded_views_preview"
android:value="true" />
<activity android:name="com.facebook.CustomTabMainActivity" />
<provider
android:name="com.facebook.internal.FacebookInitProvider"
android:authorities="com.tomasward.fredi.FacebookInitProvider"
android:exported="false" />
<receiver
android:name="com.facebook.CurrentAccessTokenExpirationBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.facebook.sdk.ACTION_CURRENT_ACCESS_TOKEN_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name="com.google.firebase.auth.internal.GenericIdpActivity"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<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:host="firebase.auth"
android:path="/"
android:scheme="genericidp" />
</intent-filter>
</activity>
<activity
android:name="com.google.firebase.auth.internal.RecaptchaActivity"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<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:host="firebase.auth"
android:path="/"
android:scheme="recaptcha" />
</intent-filter>
</activity>
<service
android:name="com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.auth.api.gms.service.START" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.tomasward.fredi.firebaseinitprovider"
android:directBootAware="true"
android:exported="false"
android:initOrder="100" />
<provider
android:name="com.luck.picture.lib.PictureFileProvider"
android:authorities="com.tomasward.fredi.luckProvider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name="com.luck.picture.lib.PictureSelectorActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorWeChatStyleActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorCameraEmptyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Picture.Theme.Translucent" />
<activity
android:name="com.luck.picture.lib.PictureCustomCameraActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PicturePreviewActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureSelectorPreviewWeChatStyleActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PictureVideoPlayActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="sensor" />
<activity
android:name="com.luck.picture.lib.PictureExternalPreviewActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.luck.picture.lib.PicturePlayAudioActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Base.Theme.NoActionBar" />
<activity
android:name="com.yalantis.ucrop.PictureMultiCuttingActivity"
android:theme="@style/Base.Theme.NoActionBar" />
<activity
android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
android:excludeFromRecents="true"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<service
android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
android:exported="true"
android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" /> <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:exported="false"
android:theme="@android:style/Theme.Translucent" />
<provider
android:name="com.google.android.gms.ads.MobileAdsInitProvider"
android:authorities="com.tomasward.fredi.mobileadsinitprovider"
android:exported="false"
android:initOrder="100" />
<service
android:name="com.google.android.gms.ads.AdService"
android:enabled="true"
android:exported="false" />
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="com.tomasward.fredi.workmanager-init"
android:directBootAware="false"
android:exported="false"
android:multiprocess="true" />
<service
android:name="androidx.work.impl.background.systemalarm.SystemAlarmService"
android:directBootAware="false"
android:enabled="@bool/enable_system_alarm_service_default"
android:exported="false" />
<service
android:name="androidx.work.impl.background.systemjob.SystemJobService"
android:directBootAware="false"
android:enabled="@bool/enable_system_job_service_default"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name="androidx.work.impl.utils.ForceStopRunnable$BroadcastReceiver"
android:directBootAware="false"
android:enabled="true"
android:exported="false" />
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$BatteryChargingProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$BatteryNotLowProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BATTERY_OKAY" />
<action android:name="android.intent.action.BATTERY_LOW" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$StorageNotLowProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
<action android:name="android.intent.action.DEVICE_STORAGE_OK" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.RescheduleReceiver"
android:directBootAware="false"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.TIME_SET" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="androidx.work.impl.background.systemalarm.ConstraintProxyUpdateReceiver"
android:directBootAware="false"
android:enabled="@bool/enable_system_alarm_service_default"
android:exported="false" >
<intent-filter>
<action android:name="androidx.work.impl.background.systemalarm.UpdateProxies" />
</intent-filter>
</receiver>
<service
android:name="androidx.room.MultiInstanceInvalidationService"
android:exported="false" />
<activity
android:name="com.twitter.sdk.android.core.identity.OAuthActivity"
android:configChanges="orientation|screenSize"
android:excludeFromRecents="true"
android:exported="false" />
</application>
</manifest>
根据要求,这里是 GeneratedPluginRegistrant.java 代码:
@Keep
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
try {
dev.gilder.tom.apple_sign_in.AppleSignInPlugin.registerWith(shimPluginRegistry.registrarFor("dev.gilder.tom.apple_sign_in.AppleSignInPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin apple_sign_in, dev.gilder.tom.apple_sign_in.AppleSignInPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.auth.FlutterFirebaseAuthPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_auth, io.flutter.plugins.firebase.auth.FlutterFirebaseAuthPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_core, io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.database.FirebaseDatabasePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_database, io.flutter.plugins.firebase.database.FirebaseDatabasePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin firebase_storage, io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin", e);
}
try {
flutterEngine.getPlugins().add(new ru.innim.flutter_login_facebook.FlutterLoginFacebookPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_login_facebook, ru.innim.flutter_login_facebook.FlutterLoginFacebookPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e);
}
try {
com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin.registerWith(shimPluginRegistry.registrarFor("com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_twitter_login, com.roughike.fluttertwitterlogin.fluttertwitterlogin.TwitterLoginPlugin", e);
}
try {
flutter.plugins.vibrate.VibratePlugin.registerWith(shimPluginRegistry.registrarFor("flutter.plugins.vibrate.VibratePlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin flutter_vibrate, flutter.plugins.vibrate.VibratePlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin google_mobile_ads, io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.googlesignin.GoogleSignInPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin google_sign_in, io.flutter.plugins.googlesignin.GoogleSignInPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.ggichure.github.hexcolor.HexcolorPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin hexcolor, com.ggichure.github.hexcolor.HexcolorPlugin", e);
}
try {
flutterEngine.getPlugins().add(new vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin image_cropper, vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin image_picker, io.flutter.plugins.imagepicker.ImagePickerPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.chavesgu.images_picker.ImagesPickerPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin images_picker, com.chavesgu.images_picker.ImagesPickerPlugin", e);
}
try {
com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin.registerWith(shimPluginRegistry.registrarFor("com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin"));
} catch(Exception e) {
Log.e(TAG, "Error registering plugin keyboard_visibility, com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin path_provider, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin shared_preferences, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
} catch(Exception e) {
Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e);
}
}
}
首先,you need to migrate your android project to v2 embedding
(引自https://github.com/hnvn/flutter_image_cropper)。那么你能试试这个吗?
其次,能否请您在您的代码中搜索您使用 com.yalantis.ucrop.UCropActivity
的地方?我想这可能是由某种构建脚本引起的,它会自动将那部分代码注入到您的 xml(但注入错误)。
第三,也许还显示你所有的依赖项。
您似乎有 2 个 activity
标签,名称为 com.yalantis.ucrop.UCropActivity
。
移动
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
进入 application
标签。
删除,
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Base.Theme.NoActionBar" />
实际答案
在一个 flutter 项目中,有三个主要的 Android 清单文件。好像是我想设置Google Ad Mob包的时候不小心插入了
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
在debug/AndroidManifest.xml,当需要进入main/AndroidManifest.xml。这导致了重复和错误。清理和构建错误后,错误消失了,但由于 google ad mob 包的设置不正确,我仍然无法 运行 应用程序。
底线:使用 google_mobile_ads
包时,请正确设置。
我只是对您的 Debug
清单感到困惑。与 Main
清单相比,重复项太多。 Debug
清单扩展了 Main
清单,所以我不确定您为什么有重复的标签。如果您希望这些活动出现在所有构建类型(发布、配置文件、调试)中,您应该将其放在 Main
清单中。
尝试删除 Debug
中的重复项。所有这些都可以在 Main
中,只有特殊权限或其他权限在 Debug
.