gpt4 book ai didi

java - Flutter 在启动时崩溃 : Didn't find class . MainActivity 在路径 DexPathList 上

转载 作者:行者123 更新时间:2023-12-03 03:16:55 24 4
gpt4 key购买 nike

我在为 Android 启用 MultiDex 构建器的情况下使用 Flutter,遇到了一个非常棘手的问题。我的应用程序运行时没有任何异常,但是当 video_player添加了软件包,它只是在启动时崩溃了:

FATAL EXCEPTION: main
Process: com.rsg.anygoal, PID: 5883
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rsg.anygoal/com.rsg.anygoal.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.rsg.anygoal.MainActivity" on path: DexPathList[[zip file "/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk"],nativeLibraryDirectories=[/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/lib/x86, /data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rsg.anygoal.MainActivity" on path: DexPathList[[zip file "/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk"],nativeLibraryDirectories=[/data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/lib/x86, /data/app/com.rsg.anygoal-tCKWlQXJD-iwdHtVRl0qqA==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
后来在调查这个问题时,我尝试禁用 MultiDex 并且似乎修复了它,但随后添加额外的 flutter 包再次破坏了应用程序,所以我认为它不是严格由 multiDex 引起的并重新启用它。
我在论坛中发现的另一个修复尝试是重命名 ".MainActivity"到确切的类路径 "com.*...*.MainActivity"但这也无济于事。
希望有人会提出一个可能的解决方法!留下一些我在调查期间收集的日志和代码 fragment ,其中可能包括对您有帮助的线索。
完整的 Android logcat 日志:https://pastebin.com/vPs614jj
Flutter pubspec(故意省略名称和描述):
version: 1.0.6+16
environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
intl: ^0.15.8
firebase_core: ^0.4.3+1
firebase_admob: ^0.9.0+10
firebase_analytics: ^5.0.9
firebase_auth: ^0.15.3
firebase_crashlytics: ^0.1.2+4
firebase_performance: ^0.3.1+5
firebase_remote_config: ^0.3.0+1
firebase_messaging: ^6.0.9
firebase_dynamic_links: ^0.5.0+9
cloud_firestore: ^0.13.0+1
cloud_functions: ^0.4.1+6
google_sign_in: ^4.1.1
provider: ^4.0.1
data_connection_checker: ^0.3.4
shared_preferences: ^0.5.6
flutter_markdown: ^0.3.2
url_launcher: ^5.4.1
barcode_scan: ^1.0.0
qr_flutter: ^3.2.0
share: ^0.6.3+5
video_player: ^0.10.11+2

dev_dependencies:
flutter_test:
sdk: flutter

flutter:
fonts:
- family: Raleway
fonts:
- asset: fonts/Raleway-Regular.ttf
uses-material-design: true
Android list :
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="$APP_DOMAIN">
<application android:name="io.flutter.app.FlutterApplication" android:label="$APP_NAME" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<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>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="$APP_ADS_ID"/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
</application>

<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
MainActivity.java:
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
Flutter Doctor 输出(XCode 无关紧要):
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.4 19E287, locale en-BG)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[!] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.46.1)
[✓] Connected device (1 available)

最佳答案

在“包名称”更改后,我遇到了类似的错误。
我的解决方案是:
在 MainActivity.kt 中更新包名称。
简而言之,所有包名称都应该相应地固定。
之后,它是固定的。

关于java - Flutter 在启动时崩溃 : Didn't find class . MainActivity 在路径 DexPathList 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62728362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com