![](/img/trans.png)
[英]java.lang.RuntimeException: Unable to instantiate activity in Flutter
[英]java.lang.RuntimeException from playstore Crashes and ANRs
這可能是重復的,但我沒有從任何帖子中找到解決方案。 從 Playstore 安裝時,我的 flutter 應用程序在啟動畫面上凍結,並且它沒有通過啟動畫面 go。 但是當我手動安裝 APK 時,它工作正常。
來自 Playstore 控制台的崩潰和 ANR 消息如下
Exception java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4918)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4955)
at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2336)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8653)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by java.lang.IllegalStateException:
at com.google.firebase.FirebaseApp.getInstance (FirebaseApp.java)
at com.google.firebase.dynamiclinks.FirebaseDynamicLinks.getInstance (FirebaseDynamicLinks.java)
at io.flutter.plugins.firebase.dynamiclinks.FlutterFirebaseDynamicLinksPlugin.getDynamicLinkInstance (FlutterFirebaseDynamicLinksPlugin.java)
at io.flutter.plugins.firebase.dynamiclinks.FlutterFirebaseDynamicLinksPlugin.onNewIntent (FlutterFirebaseDynamicLinksPlugin.java)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onNewIntent (FlutterEngineConnectionRegistry.java)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onNewIntent (FlutterEngineConnectionRegistry.java)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent (FlutterActivityAndFragmentDelegate.java)
at io.flutter.embedding.android.FlutterActivity.onNewIntent (FlutterActivity.java)
at android.app.Activity.performNewIntent (Activity.java:8222)
at android.app.Instrumentation.callActivityOnNewIntent (Instrumentation.java:1409)
at android.app.Instrumentation.callActivityOnNewIntent (Instrumentation.java:1422)
at android.app.ActivityThread.deliverNewIntents (ActivityThread.java:4085)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4901)
當我在沒有調試的情況下運行時,我在終端中收到以下消息
注意:C:\flutter.pub-cache\hosted\pub.dartlang.org\firebase_dynamic_links-5.0.11\android\src\main\java\io\flutter\plugins\firebase\dynamiclinks\FlutterFirebaseDynamicLinksPlugin.java 使用未經檢查或不安全的操作。 注意:使用 -Xlint:unchecked 重新編譯以獲取詳細信息。 注意:某些輸入文件使用或覆蓋已棄用的 API。注意:使用 -Xlint:deprecation 重新編譯以獲取詳細信息。 注意:C:\flutter.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.2.1\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java 使用未經檢查或不安全的操作。 注意:使用 -Xlint:unchecked 重新編譯以獲取詳細信息。 注意:一些輸入文件使用或覆蓋已棄用的 API。注意:使用 -Xlint:deprecation 重新編譯以獲取詳細信息。
我還嘗試完全刪除firebase_dynamic_links:^5.0.11 和 firebase_messaging: ^14.2.1 插件,但從 Playstore 安裝時,該應用程序仍凍結在啟動畫面上。
這是我的 build.gradle 文件內容
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 Exception("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: '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 33
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mosesbinzi.neba"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.gms:play-services-appset:16.0.2'
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-appcheck-playintegrity'
}`
```
在 play.google.com/console 中,選擇您的應用...現在在左側菜單中, go 進行設置,然后選擇App Integrity 。 鏈接一個包含所選應用程序的 Google Cloud 項目。
這就是解決我的問題的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.