Flutter 构建失败('无法读取包名')
Posted
技术标签:
【中文标题】Flutter 构建失败(\'无法读取包名\')【英文标题】:Flutter build Failed ('Cannot read package name')Flutter 构建失败('无法读取包名') 【发布时间】:2021-07-20 01:31:32 【问题描述】:我想构建我的 Flutter android 应用,但是当我运行“flutter build apk”时出现此错误 我见过很多解决方案,但没有人帮助我我在 build.gradle 文件中指定了 ApplicationId
* What went wrong:
Execution failed for task ':generateReleaseBuildConfig'.
> Cannot read packageName from C:\Users\hp\Desktop\wooble\android\src\main\AndroidManifest.xml
* 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 7s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 8,6s
Gradle task assembleRelease failed with exit code 1')
这是清单代码:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wooble.news">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="social_media_app"
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">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<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>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
有没有人可以帮助我,因为包是在清单文件中指定的
【问题讨论】:
能把flutter build apk -v
的输出加到pastebin里分享一下吗
pastebin.com/h8nqDJJL
【参考方案1】:
更改android/app/scr/build.gradle
中的applicationId
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.sometertiary.master"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
也可以查看这个帖子https://***.com/a/51550358/9398610
【讨论】:
以上是关于Flutter 构建失败('无法读取包名')的主要内容,如果未能解决你的问题,请参考以下文章
Flutter:FAILURE:构建失败,出现异常无法创建任务':app:compileFlutterBuildDebug'。必须提供 Flutter 源码目录
为啥 Flutter 构建失败并出现错误无法解析配置“:app:debugRuntimeClasspath”的所有文件
在发布模式下构建后 Flutter Secure Storage 无法正常工作