Flutter android 签名发布后尝试调试时应用程序崩溃
Flutter android App crashes when trying to debug after signing release
我是 Flutter 的新手,正在构建一个 Flutter 应用程序作为学校项目的一部分。我和我的团队正在构建 ios、android 和网络应用程序版本,我的任务是生成并签署我的应用程序包以在 google 游戏中发布。我能够成功签署捆绑包并上传项目。我无法在模拟器上测试发布版本,但这是另一个可能相关的问题。
说正点,我现在在调试我的应用程序时遇到了问题。在重命名和配置构建类型之前没有问题,我只是使用默认应用程序 ID 并 运行 在 VScode 中启用调试器。我的应用程序似乎构建成功(我想是因为我没有收到任何错误)但它没有正确安装在模拟器上。我在模拟器上收到一个弹出通知,不幸的是该应用程序一直在关闭。在捕获日志中,我看到“正在等待天文台端口可用...”。
我已经重置了模拟器,flutter clean 并重建。我在 android 工作室(调试)中尝试过 running/cleaning/building 无济于事。
这是捕获日志。我没有将它们全部包括在内,因为应用程序似乎正在正确构建。
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementReceiver" (Raw: "com.google.android.gms.measurement.AppMeasurementReceiver")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: receiver (line=177)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" (Raw: "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver")
A: android:permission(0x01010006)="android.permission.INSTALL_PACKAGES" (Raw: "android.permission.INSTALL_PACKAGES")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0xffffffff
E: intent-filter (line=182)
E: action (line=183)
A: android:name(0x01010003)="com.android.vending.INSTALL_REFERRER" (Raw: "com.android.vending.INSTALL_REFERRER")
E: service (line=187)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementService" (Raw: "com.google.android.gms.measurement.AppMeasurementService")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: service (line=191)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementJobService" (Raw: "com.google.android.gms.measurement.AppMeasurementJobService")
A: android:permission(0x01010006)="android.permission.BIND_JOB_SERVICE" (Raw: "android.permission.BIND_JOB_SERVICE")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: provider (line=197)
A: android:name(0x01010003)="com.google.firebase.provider.FirebaseInitProvider" (Raw: "com.google.firebase.provider.FirebaseInitProvider")
A: android:exported(0x01010010)=(type 0x12)0x0
A: android:authorities(0x01010018)="com.sensationalscience.sensational_science.firebaseinitprovider" (Raw: "com.sensationalscience.sensational_science.firebaseinitprovider")
A: android:initOrder(0x0101001a)=(type 0x10)0x64
E: meta-data (line=203)
A: android:name(0x01010003)="com.google.android.gms.version" (Raw: "com.google.android.gms.version")
A: android:value(0x01010024)=@0x7f080004
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +6 ms] Stopping app 'app.apk' on Android SDK built for x86.
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am force-stop com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +44 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +215 ms] package:com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +2 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell cat /data/local/tmp/sky.com.sensationalscience.sensational_science.sha1
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +24 ms] 2ef7da51e6c1f4f4170671be4372471e59f61ee6
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] Installing APK.
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +1 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe version
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +16 ms] Android Debug Bridge version 1.0.41
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== Version 29.0.6-6198805
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== Installed as C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [{"event":"app.progress","params":{"appId":"bc8e3997-0174-4387-ae07-3b6f69cdc04d","id":"1","progressId":null,"message":"Installing build\app\outputs\apk\app.apk..."}}]
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +17 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 install -t -r C:\Users\Lauren\Documents\School7\sensational_science\build\app\outputs\apk\app.apk
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [+3493 ms] Performing Streamed Install
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== Success
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [{"event":"app.progress","params":{"appId":"bc8e3997-0174-4387-ae07-3b6f69cdc04d","id":"1","progressId":null,"finished":true}}]
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +1 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell echo -n cc0ff10c7a448e68c958b5ace7858fca4554ee4e > /data/local/tmp/sky.com.sensationalscience.sensational_science.sha1
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +31 ms] Android SDK built for x86 startApp
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +2 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true com.sensationalscience.sensational_science/com.sensationalscience.sensational_science.MainActivity
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +95 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.sensationalscience.sensational_science/.MainActivity (has extras) }
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ ] Waiting for observatory port to be available...
Tue May 05 2020 [12:23:20 GMT-0600 (Mountain Daylight Time)] Log file ended
这是我的应用级别 build.gradle。请注意我的构建类型。我不确定这些配置是否正确。我遵循 https://flutter.dev/docs/deployment/android 但他们对如何设置构建类型的解释有限。
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // connection to firebase
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.sensationalscience.sensational_science"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode = flutterVersionCode.toInteger()
versionName flutterVersionName
}
//**Note in my app I have the correct key info I just replaced the information here.
signingConfigs {
release {
keyAlias keystoreProperties['xx']
keyPassword keystoreProperties['xx']
storeFile keystoreProperties['C:\Keystore\xx'] ? file(keystoreProperties['xx']) : null
storePassword keystoreProperties['xx']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2' // connect to firebase analytics
implementation 'com.google.firebase:firebase-auth:19.3.0' // connect to firebase authentication
implementation 'com.google.firebase:firebase-firestore:21.4.2' // connect to firebase coud firestore
implementation 'com.android.support:multidex:1.0.3' // allow more than 64k methods with multidex enabling
}
这是我的 android 清单。我想知道 MainActivy 是否是问题所在。我不太确定 where/what 那个文件到底是什么,并且在捕获日志的末尾有一个在启动 Intent 时对它的引用。
``
package="com.sensationalscience.sensational_science">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 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="sensational_science"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- 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>
<!-- Add UCrop Activity for image cropping (MPJ 4/21/20)-->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- 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" />
</application>
这是我的build.gradle。我收到此错误 Could not 运行 phased build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.6.2-all.zip'。
无法启动守护进程。
此问题可能是由于守护程序配置不正确造成的。
例如,使用了无法识别的 jvm 选项。
请参阅 https://docs.gradle.org/5.6.2/userguide/gradle_daemon.html
处有关守护程序的用户手册章节
处理命令行:C:\Program Files (x86)\Java\jdk1.8.0_172\bin\java.exe -Xmx1536M -Dfile.encoding=utf8 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\Lauren.gradle\wrapper\dists\gradle-5.6.2-allst6wgf78h16so49nn74lgtbb\gradle-5.6.2\lib\gradle-launcher-5.6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.2
请阅读以下过程输出以了解更多信息:
虚拟机初始化时出错
无法为 1572864KB 对象预留足够 space heapJava(0)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3' // for connecting to firebase
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
编辑:我添加到捕获日志
编辑:添加 android 工作室崩溃详细信息:
--------- beginning of crash
2020-05-05 13:37:49.148 13524-13524/com.sensationalscience.sensational_science E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sensationalscience.sensational_science, PID: 13524
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sensationalscience.sensational_science/com.sensationalscience.sensational_science.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.sensationalscience.sensational_science.MainActivity" on path: DexPathList[[zip file "/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/lib/x86, /data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sensationalscience.sensational_science.MainActivity" on path: DexPathList[[zip file "/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/lib/x86, /data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
我已经解决了这个问题。当我更改应用程序 name/ID 时,我不小心更改了 MainActivity.java class 名称。我将 class 名称从 Sensational Science 更改为 MainActivity。
package com.sensationalscience.sensational_science
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
我是 Flutter 的新手,正在构建一个 Flutter 应用程序作为学校项目的一部分。我和我的团队正在构建 ios、android 和网络应用程序版本,我的任务是生成并签署我的应用程序包以在 google 游戏中发布。我能够成功签署捆绑包并上传项目。我无法在模拟器上测试发布版本,但这是另一个可能相关的问题。
说正点,我现在在调试我的应用程序时遇到了问题。在重命名和配置构建类型之前没有问题,我只是使用默认应用程序 ID 并 运行 在 VScode 中启用调试器。我的应用程序似乎构建成功(我想是因为我没有收到任何错误)但它没有正确安装在模拟器上。我在模拟器上收到一个弹出通知,不幸的是该应用程序一直在关闭。在捕获日志中,我看到“正在等待天文台端口可用...”。
我已经重置了模拟器,flutter clean 并重建。我在 android 工作室(调试)中尝试过 running/cleaning/building 无济于事。
这是捕获日志。我没有将它们全部包括在内,因为应用程序似乎正在正确构建。
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementReceiver" (Raw: "com.google.android.gms.measurement.AppMeasurementReceiver")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: receiver (line=177)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" (Raw: "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver")
A: android:permission(0x01010006)="android.permission.INSTALL_PACKAGES" (Raw: "android.permission.INSTALL_PACKAGES")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0xffffffff
E: intent-filter (line=182)
E: action (line=183)
A: android:name(0x01010003)="com.android.vending.INSTALL_REFERRER" (Raw: "com.android.vending.INSTALL_REFERRER")
E: service (line=187)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementService" (Raw: "com.google.android.gms.measurement.AppMeasurementService")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: service (line=191)
A: android:name(0x01010003)="com.google.android.gms.measurement.AppMeasurementJobService" (Raw: "com.google.android.gms.measurement.AppMeasurementJobService")
A: android:permission(0x01010006)="android.permission.BIND_JOB_SERVICE" (Raw: "android.permission.BIND_JOB_SERVICE")
A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
A: android:exported(0x01010010)=(type 0x12)0x0
E: provider (line=197)
A: android:name(0x01010003)="com.google.firebase.provider.FirebaseInitProvider" (Raw: "com.google.firebase.provider.FirebaseInitProvider")
A: android:exported(0x01010010)=(type 0x12)0x0
A: android:authorities(0x01010018)="com.sensationalscience.sensational_science.firebaseinitprovider" (Raw: "com.sensationalscience.sensational_science.firebaseinitprovider")
A: android:initOrder(0x0101001a)=(type 0x10)0x64
E: meta-data (line=203)
A: android:name(0x01010003)="com.google.android.gms.version" (Raw: "com.google.android.gms.version")
A: android:value(0x01010024)=@0x7f080004
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +6 ms] Stopping app 'app.apk' on Android SDK built for x86.
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am force-stop com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +44 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +215 ms] package:com.sensationalscience.sensational_science
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +2 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell cat /data/local/tmp/sky.com.sensationalscience.sensational_science.sha1
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +24 ms] 2ef7da51e6c1f4f4170671be4372471e59f61ee6
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] Installing APK.
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +1 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe version
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +16 ms] Android Debug Bridge version 1.0.41
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== Version 29.0.6-6198805
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== Installed as C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ ] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [{"event":"app.progress","params":{"appId":"bc8e3997-0174-4387-ae07-3b6f69cdc04d","id":"1","progressId":null,"message":"Installing build\app\outputs\apk\app.apk..."}}]
[12:19:52 PM] [FlutterRun] [Info] [Flutter] <== [ +17 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 install -t -r C:\Users\Lauren\Documents\School7\sensational_science\build\app\outputs\apk\app.apk
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [+3493 ms] Performing Streamed Install
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== Success
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [{"event":"app.progress","params":{"appId":"bc8e3997-0174-4387-ae07-3b6f69cdc04d","id":"1","progressId":null,"finished":true}}]
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +1 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell echo -n cc0ff10c7a448e68c958b5ace7858fca4554ee4e > /data/local/tmp/sky.com.sensationalscience.sensational_science.sha1
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +31 ms] Android SDK built for x86 startApp
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +2 ms] executing: C:\Users\Lauren\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true com.sensationalscience.sensational_science/com.sensationalscience.sensational_science.MainActivity
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ +95 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.sensationalscience.sensational_science/.MainActivity (has extras) }
[12:19:56 PM] [FlutterRun] [Info] [Flutter] <== [ ] Waiting for observatory port to be available...
Tue May 05 2020 [12:23:20 GMT-0600 (Mountain Daylight Time)] Log file ended
这是我的应用级别 build.gradle。请注意我的构建类型。我不确定这些配置是否正确。我遵循 https://flutter.dev/docs/deployment/android 但他们对如何设置构建类型的解释有限。
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // connection to firebase
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.sensationalscience.sensational_science"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode = flutterVersionCode.toInteger()
versionName flutterVersionName
}
//**Note in my app I have the correct key info I just replaced the information here.
signingConfigs {
release {
keyAlias keystoreProperties['xx']
keyPassword keystoreProperties['xx']
storeFile keystoreProperties['C:\Keystore\xx'] ? file(keystoreProperties['xx']) : null
storePassword keystoreProperties['xx']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2' // connect to firebase analytics
implementation 'com.google.firebase:firebase-auth:19.3.0' // connect to firebase authentication
implementation 'com.google.firebase:firebase-firestore:21.4.2' // connect to firebase coud firestore
implementation 'com.android.support:multidex:1.0.3' // allow more than 64k methods with multidex enabling
}
这是我的 android 清单。我想知道 MainActivy 是否是问题所在。我不太确定 where/what 那个文件到底是什么,并且在捕获日志的末尾有一个在启动 Intent 时对它的引用。 ``
package="com.sensationalscience.sensational_science">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 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="sensational_science"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- 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>
<!-- Add UCrop Activity for image cropping (MPJ 4/21/20)-->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- 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" />
</application>
这是我的build.gradle。我收到此错误 Could not 运行 phased build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.6.2-all.zip'。 无法启动守护进程。 此问题可能是由于守护程序配置不正确造成的。 例如,使用了无法识别的 jvm 选项。 请参阅 https://docs.gradle.org/5.6.2/userguide/gradle_daemon.html
处有关守护程序的用户手册章节处理命令行:C:\Program Files (x86)\Java\jdk1.8.0_172\bin\java.exe -Xmx1536M -Dfile.encoding=utf8 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\Lauren.gradle\wrapper\dists\gradle-5.6.2-allst6wgf78h16so49nn74lgtbb\gradle-5.6.2\lib\gradle-launcher-5.6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.2 请阅读以下过程输出以了解更多信息: 虚拟机初始化时出错 无法为 1572864KB 对象预留足够 space heapJava(0)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3' // for connecting to firebase
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
编辑:我添加到捕获日志
编辑:添加 android 工作室崩溃详细信息:
--------- beginning of crash
2020-05-05 13:37:49.148 13524-13524/com.sensationalscience.sensational_science E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sensationalscience.sensational_science, PID: 13524
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sensationalscience.sensational_science/com.sensationalscience.sensational_science.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.sensationalscience.sensational_science.MainActivity" on path: DexPathList[[zip file "/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/lib/x86, /data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sensationalscience.sensational_science.MainActivity" on path: DexPathList[[zip file "/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/lib/x86, /data/app/com.sensationalscience.sensational_science-TWyC0kIWuswGoy1G-VAtCQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
我已经解决了这个问题。当我更改应用程序 name/ID 时,我不小心更改了 MainActivity.java class 名称。我将 class 名称从 Sensational Science 更改为 MainActivity。
package com.sensationalscience.sensational_science
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}