The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
bianxiangdeMacBook-Pro:swapwallet-app bianxiang$ flutter build apk
Initializing gradle... 0.7s
Resolving dependencies... 1.4s
/Users/bianxiang/swapwallet-app/android/app/src/main/AndroidManifest.xml:13:13-64 Error:
Attribute provider#androidx.core.content.FileProvider@authorities value=(com.einsh.swap_app.fileProvider) from [:flutter_bugly] AndroidManifest.xml:13:13-64
is also present at [:flutter_webview_plugin] AndroidManifest.xml:11:13-64 value=(com.einsh.swap_app.fileprovider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:11:9-19:20 to override.
/Users/bianxiang/swapwallet-app/android/app/src/main/AndroidManifest.xml:18:17-55 Error:
Attribute meta-data#android.support.FILE_PROVIDER_PATHS@resource value=(@xml/provider_paths) from [:flutter_bugly] AndroidManifest.xml:18:17-55
is also present at [:flutter_webview_plugin] AndroidManifest.xml:17:17-50 value=(@xml/filepaths).
Suggestion: add 'tools:replace="android:resource"' to <meta-data> element at AndroidManifest.xml to override.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseManifest'.
> 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 2s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 2.9s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
报错里有提示在manifest里加tools:replace="android:authorities"和android:resource,记得在最外层加上xmlns:tools="http://schemas.android.com/tools"
以下是改动后的最新的manifest文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.einsh.swap_app">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<!-- 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="SWAP"
android:icon="@mipmap/ic_launcher">
<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
tools:replace="android:resource" />
</provider>
</application>
</manifest>
再次打包时需要加入cpu架构适配
flutter build apk --release --target-platform android-arm