飞镖/颤振:应用程序在启动时崩溃
我有一个非常有趣的问题,我可以在模拟器上运行应用程序, flutter build apk
成功,我可以在Google上发布新版本播放或仅在手机上安装 apk
(Pixel 2 XL,当前于4月发布安全补丁)。
I have this very interesting issue, where I can run my application on the emulator just fine, flutter build apk
is successful, I can either release the new version on Google Play or just install the apk
on my phone (Pixel 2 XL, currently on April security patch).
但是当我在手机上启动它时,它立即崩溃。我还没有尝试安装 debug apk
,首先,我想应用May补丁。
But when I launch it on my phone, it instantly crashes. I haven't tried installing the debug apk
yet, first I want to apply the May patch.
我已经尝试几次升级振颤,但那里似乎也没有任何问题:
I already tried upgrading flutter several times, but doesn't seem to be any issue there either:
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!
我最近更换了笔记本电脑,并在此新笔记本电脑上签出了我的代码的git存储库。有一些问题,但我最终解决了。唯一的区别是,项目名称现在只是 osszefogasaszanhuzokert
,而软件包名称是 osszefogasaszanhuzokert2
-但是我不知道
I recently switched laptops and checked out the git repository of my code on this new one. There were some problems, but I eventually fixed those. The only difference is that that the project name now is simply osszefogasaszanhuzokert
, while the package name is osszefogasaszanhuzokert2
- but I don't think this should cause any problem.
我的猜测是问题将出在我的 AndroidManifest.xml
中>:
My guess is that the problem will lie somewhere in my 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>
Android studio将几个属性标记为不允许,但正如您所见,我几乎将所有属性保留为默认值-除了出于明显原因更改了 android:label
。
Android studio marks several attributes as not allowed, but as you can see I pretty much left everything as default - except I changed the android:label
for obvious reasons.
编辑:我安装了调试apk并运行完美。但是,我能够获得发行版APK崩溃的adb logcat,问题似乎出在以下方面:
I installed the debug apk and it runs perfectly. However, I was able to get adb logcat of the crash of the release apk, and the problem seems to be the following:
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'
如何更改 Dart VM
以使用 hardfp
而不是 softfp
?
How could I change the Dart VM
to use hardfp
instead of softfp
?
我遇到了同样的问题。对我来说,这是在我重命名应用程序并更改了程序包名称之后发生的。我没有为Android正确执行此操作。
I had the same issue. For me this happened after I renamed my app and changed the package name. I did not do this properly for android.
遵循此更改包名称的指南,对于android来说一切正常。
After following this guide of how to change the package name, things worked fine for android.
请确保 AndroidManifest.xml
和 android / app / build.gradle
和 android / app / src /。 ../ MainActivity.java
相同。