0
votes

I have installed android studio on my pc and I have also installed flutter and Dart plugin but when I run "flutter run" I get this error, please help me out

This is the error

PS C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp> flutter run Using hardware rendering with device sdk gphone x86 arm. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib\main.dart on sdk gphone x86 arm in debug mode... Running Gradle task 'assembleDebug'... Running Gradle task 'assembleDebug'... Done 28.0s √ Built build\app\outputs\flutter-apk\app-debug.apk. cmd: Can't find service: activity Installing build\app\outputs\flutter-apk\app.apk... 1.8s Error: ADB exited with exit code 1 Performing Streamed Install

adb: failed to install C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp\build\app\outputs\flutter-apk\app.apk: cmd: Can't find service: package Error launching application on sdk gphone x86 arm.

windows 10 Operating system

1

1 Answers

0
votes

Run the command:

flutter doctor -v

If everything looks good, then it means that it's a configuration issue. Check your android manifest, and make sure that you have set your MainActivity with the proper intent filters. It needs a main intent filter, in order to launch the app.

Please also make sure that you have followed all the points in the flutter documentation, and setting up flutter on a windows machine:

https://flutter.dev/docs/get-started/install/windows

Then check your build.gradle file (on the app module) and make sure that it looks like this:

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

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

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

android {

    compileSdkVersion 30

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

    compileOptions {
      sourceCompatibility 1.8
      targetCompatibility 1.8
    }

    defaultConfig {
        applicationId “[YOUR PACKAGE]”
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName       
        multiDexEnabled true
    }

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

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }  
        release {
           signingConfig signingConfigs.release
       }
    }

    lintOptions { 
        checkReleaseBuilds false    
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

If you are running in debug mode, then you should not worry about release configurations, but it's there in case anyone needs it.

Make sure that you have accepted all android licences. If there are any issues, then the flutter doctor will tell you about it.