6

I am new to this bare with me.

I am running my code in VS

I am trying to RUN my FLUTTER app and i keep getting error:

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. 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

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.

2 Answers 2

16

perhaps the issue is because flutter can't access your App on launch due to flutter/dart configuration in your project structure. Maybe you can try default Flutter Application name in your AndroidManifest.xml. See image below.

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

AndroidManifest.xml

Sign up to request clarification or add additional context in comments.

4 Comments

instead of image, consider including code snippets (along with image if you are illustrating something).
@HarleyRegua Yeah that was the issue. Thanks. Resolved it
Great this answer helped me too
Actually, android:name should be updated to android:name="${applicationName}" according to the official guidelines.
0

Actually the answer is to modify android\app\src\main\kotlin\com\example\sm_client_flutter\MainActivity.kt to use your new project name: com.oneclick.errands.Application

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.