Flutter AppBundle 每次打开时都会崩溃

Flutter AppBundle Crash Everytime When Opens

有人可以帮助我吗?我正在努力解决这个问题。我完成了关于我的代码的一切。它在模拟器上 运行 完美,同时通过 USB 使用我的 phone 进行调试。但我试图发布 appbundle 以玩商店,我做到了。但是我从 Play 商店下载了 apk 到我的 phone。我单击显示此错误的应用程序。我尝试了很多解决方案,颤抖干净,将我的频道切换到稳定,掌握。请帮帮我,我要疯了。也许我的主要活动 kotlin 文件 idk 有问题。

  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.app.lab_tip/com.example.app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/base.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.ar.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.arm64_v8a.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.tr.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/lib/arm64, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/base.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.ar.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.tr.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3234)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3459)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2046)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:225)
    at android.app.ActivityThread.main(ActivityThread.java:7564)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/base.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.ar.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.arm64_v8a.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.tr.apk", zip file "/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/lib/arm64, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/base.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.ar.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.tr.apk!/lib/arm64-v8a, /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
    at androidx.core.app.CoreComponentFactory.instantiateActivity(Unknown Source:0)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1251)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3222)
    ... 11 more
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.ar.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:369)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:457)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:853)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:952)
        at android.app.LoadedApk.getResources(LoadedApk.java:1190)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2474)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2466)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6453)
        at android.app.ActivityThread.access00(ActivityThread.java:226)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
        ... 6 more
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.arm64_v8a.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:369)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:457)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:853)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:952)
        at android.app.LoadedApk.getResources(LoadedApk.java:1190)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2474)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2466)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6453)
        at android.app.ActivityThread.access00(ActivityThread.java:226)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
        ... 6 more
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.tr.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:369)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:457)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:853)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:952)
        at android.app.LoadedApk.getResources(LoadedApk.java:1190)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2474)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2466)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6453)
        at android.app.ActivityThread.access00(ActivityThread.java:226)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
        ... 6 more
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.app.lab_tip-soid4kk75i6xaFaTqLdw1A==/split_config.xxhdpi.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:369)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:457)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:853)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:952)
        at android.app.LoadedApk.getResources(LoadedApk.java:1190)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2474)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2466)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6453)
        at android.app.ActivityThread.access00(ActivityThread.java:226)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
        ... 6 more



[√] Flutter (Channel master, 2.1.0-13.0.pre.192, on Microsoft Windows [Version 10.0.19042.867], locale tr-TR)
    • Flutter version 2.1.0-13.0.pre.192 at C:\src\flutter
    • Framework revision c0bcb4fc16 (24 hours ago), 2021-03-19 16:34:57 -0700
    • Engine revision e6db3a275e
    • Dart version 2.13.0 (build 2.13.0-149.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users506\AppData\Local\Android\sdk
    • Platform android-S, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.54.3)
    • VS Code at C:\Users506\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.13.2

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 89.0.774.57

• No issues found!



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 = '3'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '3'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

def billing_version = "3.0.0"

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 30
    ndkVersion "22.0.7026061"

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.app.lab_tip"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        ndk {
            debugSymbolLevel 'SYMBOL_TABLE'
        }
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
        debug {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            ndk {
                debugSymbolLevel 'SYMBOL_TABLE'
            }
            signingConfig signingConfigs.release
        }
        debug{
            ndk {
                debugSymbolLevel 'SYMBOL_TABLE'
            }
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.android.gms:play-services-ads:19.8.0'
    implementation "com.android.billingclient:billing:$billing_version"
    implementation 'com.google.android.material:material:1.3.0'
}


buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.5'
    }
}

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
}


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.lab_tip">
    <!-- 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. -->
    <uses-permission android:name="com.android.vending.BILLING"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:label="lab_tip">
        <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>
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-9394268775057524~4526168215"/>
        <!-- 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>
</manifest>

我也有同样的问题,但那是因为我使用了 google 地图包。但是当我添加 proguard 配置时,我的问题得到了解决。查看此 link 以获得有关如何完成的详细说明。 https://github.com/flutter/flutter/issues/69820.