簡體   English   中英

運行命令“flutter run”時出錯

[英]Error when running the command “flutter run”

我已經在我的電腦上安裝了 android studio,我還安裝了 flutter 和 Dart 插件,但是當我運行“flutter run”時出現此錯誤,請幫幫我

這是錯誤

PS C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp> flutter run Using hardware rendering with device sdk gphone x86 arm. 如果您注意到圖形偽影,請考慮使用“--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\應用程序調試.apk。 cmd:找不到服務:活動正在安裝 build\app\outputs\flutter-apk\app.apk... 1.8s 錯誤: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 操作系統

運行命令:

flutter doctor -v

如果一切看起來都很好,那么這意味着這是一個配置問題。 檢查您的 android 清單,並確保您已使用正確的意圖過濾器設置 MainActivity。 它需要一個主要的意圖過濾器才能啟動應用程序。

另請確保您已遵循 flutter 文檔中的所有要點,並在 windows 機器上設置 flutter:

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

然后檢查您的 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 = '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"
}

如果您在調試模式下運行,那么您不應該擔心發布配置,但它存在以防萬一有人需要它。

確保您已接受所有 android 許可證。 如果有任何問題,那么 flutter 醫生會告訴你的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM