简体   繁体   English

颤振错误:java.lang.RuntimeException:无法实例化应用程序

[英]FLUTTER ERROR: java.lang.RuntimeException: Unable to instantiate application

I am new to this bare with me.我对这个裸露的我很陌生。

I am running my code in VS我在 VS 中运行我的代码

I am trying to RUN my FLUTTER app and i keep getting error:我正在尝试运行我的 FLUTTER 应用程序,但我不断收到错误消息:

Launching lib\main.dart on TECNO LC6 in debug mode...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
E/AndroidRuntime(32535): FATAL EXCEPTION: main
E/AndroidRuntime(32535): Process: com.oneclick.errands, PID: 32535
E/AndroidRuntime(32535): java.lang.RuntimeException: Unable to instantiate application com.oneclick.errands.Application: java.lang.ClassNotFoundException: Didn't find class "com.oneclick.errands.Application" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/base.apk"],nativeLibraryDirectories=[/data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/lib/arm, /data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/base.apk!/lib/armeabi-v7a, /system/lib]]
E/AndroidRuntime(32535): at android.app.LoadedApk.makeApplication(LoadedApk.java:1069)
E/AndroidRuntime(32535): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5923)
E/AndroidRuntime(32535): at android.app.ActivityThread.access$1200(ActivityThread.java:213)
E/AndroidRuntime(32535): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
E/AndroidRuntime(32535): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(32535): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(32535): at android.app.ActivityThread.main(ActivityThread.java:6758)
E/AndroidRuntime(32535): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32535): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
E/AndroidRuntime(32535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)
E/AndroidRuntime(32535): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.oneclick.errands.Application"
on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/base.apk"],nativeLibraryDirectories=[/data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/lib/arm, /data/app/com.oneclick.errands-9wup51WXGNuAJqp8P2doyw==/base.apk!/lib/armeabi-v7a, /system/lib]]
E/AndroidRuntime(32535): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
E/AndroidRuntime(32535): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(32535): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(32535): at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
E/AndroidRuntime(32535): at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
E/AndroidRuntime(32535): at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
E/AndroidRuntime(32535): at android.app.LoadedApk.makeApplication(LoadedApk.java:1061)
E/AndroidRuntime(32535): ... 9 more

Then it hangs on the last step.然后它挂在最后一步。 I even left it for 3 hours n got impatient.我什至把它放了 3 个小时,不耐烦了。 I have tried to add as much relevant information as I cam but the system wants me to add more info but i have said i have to say.我试图添加尽可能多的相关信息,但系统希望我添加更多信息,但我已经说过我必须说。 Now i am just typing to get rid of this warning.现在我只是打字来摆脱这个警告。

!!!HELP!!! !!!帮助!!!

My build.gradle我的 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 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 = '2'
}

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

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

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 29

    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.oneclick.errands"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        //Added to fix error <FirebaseCorePlugin.java uses unchecked or unsafe operations>
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
//            signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-messaging:20.1.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    //Added to fix error <FirebaseCorePlugin.java uses unchecked or unsafe operations>
    implementation 'com.android.support:multidex:1.0.3'
}

apply plugin: 'com.google.gms.google-services'


Thank you for your time.感谢您的时间。

perhaps the issue is because flutter can't access your App on launch due to flutter/dart configuration in your project structure.也许问题是由于项目结构中的 flutter/dart 配置,flutter 无法在启动时访问您的应用程序。 Maybe you can try default Flutter Application name in your AndroidManifest.xml.也许您可以在 AndroidManifest.xml 中尝试默认 Flutter 应用程序名称。 See image below.见下图。

<application android:name="io.flutter.app.FlutterApplication" android:label="AppLabel">

AndroidManifest.xml AndroidManifest.xml

其实答案是修改 android\\app\\src\\main\\kotlin\\com\\example\\sm_client_flutter\\MainActivity.kt 使用你的新项目名称:com.oneclick.errands.Application

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM