我有一个非常有趣的问题,我可以在模拟器上很好flutter build apk地运行我的应用程序成功,可以在Google Play上发布新版本,也可以apk在手机上安装新版本(Pixel 2 XL,目前在4月发布安全补丁) 。
但是,当我在手机上启动它时,它立即崩溃。我还没有尝试安装debug apk,首先,我想应用May补丁。
我已经尝试了几次升级颤振,但那里似乎也不是什么问题:
C:\Android\osszefogasaszanhuzokert>flutter upgrade
Upgrading Flutter from c:\Android\flutter...
From https://github.com/flutter/flutter
3d3673a34..23098dde5 master -> origin/master
Already up to date.
Upgrading engine...
Already up-to-date.
Flutter 0.3.6-pre.81 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 2849bc04ff (10 days ago) • 2018-05-01 20:07:45 -0700
Engine • revision d5c1117170
Tools • Dart 2.0.0-dev.52.0.flutter-011676641a
Running "flutter packages upgrade" in osszefogasaszanhuzokert... 14.4s
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel beta, v0.3.6-pre.81, on Microsoft Windows [Version 10.0.15063], locale en-GB)
[?] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[?] Android Studio (version 3.1)
[?] Connected devices (1 available)
• No issues found!
Run Code Online (Sandbox Code Playgroud)
我最近更换了笔记本电脑,并在此新笔记本电脑上签出了我的代码的git存储库。有一些问题,但我最终解决了。唯一的区别是,项目名称现在为simple osszefogasaszanhuzokert,而程序包名称为osszefogasaszanhuzokert2-,但我认为这不会引起任何问题。
我的猜测是问题将出在我的某个地方AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zgyorkei.osszefogasaszanhuzokert2">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<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="Összefogás A Szánhúzókért"
android:icon="@mipmap/ic_launcher">
<activity
android:name="com.zgyorkei.osszefogasaszanhuzokert2.MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
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>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
Android studio标记了几个不允许的属性,但是正如您所看到的,我几乎将所有内容都保留为默认设置-除非android:label出于明显的原因更改了。
编辑:我安装了调试apk,它运行完美。但是,我能够获得发行版apk崩溃的adb logcat,问题似乎出在以下方面:
05-12 07:38:23.341 29595 29595 I crash_dump32: performing dump of process 29560 (target tid = 29560)
05-12 07:38:23.341 29595 29595 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-12 07:38:23.341 29595 29595 F DEBUG : Build fingerprint: 'google/taimen/taimen:8.1.0/OPM2.171019.029.B1/4720900:user/release-keys'
05-12 07:38:23.341 29595 29595 F DEBUG : Revision: 'rev_10'
05-12 07:38:23.341 29595 29595 F DEBUG : ABI: 'arm'
05-12 07:38:23.341 29595 29595 F DEBUG : pid: 29560, tid: 29560, name: saszanhuzokert2 >>> com.zgyorkei.osszefogasaszanhuzokert2 <<<
05-12 07:38:23.342 29595 29595 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
05-12 07:38:23.343 29595 29595 F DEBUG : Abort message: '[FATAL:flutter/runtime/dart_vm.cc(409)] Error while initializing the Dart VM: Snapshot not compatible with the current VM configuration: the snapshot requires 'product no-type_checks no-asserts no-error_on_bad_type no-error_on_bad_override arm-eabi hardfp' but the VM has 'product no-type_checks no-asserts no-error_on_bad_type no-error_on_bad_override arm-eabi softfp'
Run Code Online (Sandbox Code Playgroud)
如何更改而不是Dart VM使用?hardfpsoftfp
Leb*_*ele 22
我遇到过同样的问题。对我来说,这是在我重命名应用程序并更改了程序包名称之后发生的。我没有针对Android正确执行此操作。
在遵循了如何更改包名的指南之后,对于android来说一切正常。
在确保程序包名称AndroidManifest.xml和android/app/build.gradle和android/app/src/.../MainActivity.java是一样的。
tem*_*bek 19
这不是这个问题的直接答案,但是我遇到了类似的问题,并且到这里为止。其他人也可以来。
我的问题:应用在模拟器上首次启动时会崩溃
我的解决方案:通过运行清除缓存flutter clean
ram*_*man 15
解决此错误的最简单方法
更改包名称时会发生此错误
为了以正确的方式更改您的包名称,您必须按照以下步骤操作
按照以下步骤您可以解决此错误
第1步:-
1.前往:---
项目>[your_app_name]>Android [your_app_name]>app>src
在 src 文件夹中,您可以找到 3 个文件 Debug、main 和 profile
去每个文件单独和他们的变化包名的AndroidManifest.xml文件
现在,您离解决这个错误已经有一半了。
第2步:-
现在,转到位于的 build.gradle 文件
项目>[your_app_name]>Android [your_app_name]>app>build.gradle
在这里你可以找到这个代码 defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.appname"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
只需将包名更改 com.example.appname为您合适的包名
第 3 步:-
现在去
项目>[your_app_name]>Android [your_app_name]>app>src>main> java>mainactivity
***注意****** 如果你使用带有颤振的 Kotlin,那么你必须去这里:--
项目>[your_app_name]>Android [your_app_name]>app>src>main> kotlin>mainactivity
转到Mainactivity.kotlin或mainactivity.java后,您可以更改应用程序的包名称
它应该可以完美运行...请对此提供反馈。
也不要忘记更改文件夹的包名称 [转到 src>main>kotlin 或 java>com.example.app ]
某些具有不同架构的手机也存在相同的问题。当我打开应用程序时,它开始崩溃。这是一个对我有用的修复程序:
defaultConfig {
...
multiDexEnabled true
ndk {
abiFilters 'x86', 'armeabi-v7a'
}
}
Run Code Online (Sandbox Code Playgroud)
不得不添加ndk的android/app/build.gradle文件和它的工作就像一个魅力。
我希望这可以帮助某人。
我遇到了同样的问题,这里的所有选项都没有帮助我。最后,我发现了logcat并意识到我的应用程序因为 Crashlytics 包而崩溃。
简而言之,我在终端中运行了以下命令以显示来自设备的日志,这不仅帮助我找到了罪魁祸首,而且帮助我解决了问题。您可以让它在后台运行。
adb logcat
Run Code Online (Sandbox Code Playgroud)
您可能必须将以下路径添加到path环境变量中。或者只是cd为了它。
C:\Users\[USERNAME]\AppData\Local\Android\sdk\platform-tools
请参阅下面的输出。我敢肯定,如果由于任何原因再次发生这种情况,我应该能够找出原因,而不是猜测是什么原因造成的。
颤振升级后我遇到了同样的问题。
在我的应用程序中,multiDexEnabled true已在文件中启用build.gradle,并且在升级之前工作正常。我之前添加它是为了修复另一个崩溃。
请参阅此相同内容:如果我包含某个包,Flutter Android 应用程序在启动时崩溃
| 归档时间: |
|
| 查看次数: |
11634 次 |
| 最近记录: |