首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行"flutter run“命令时出错

运行"flutter run“命令时出错
EN

Stack Overflow用户
提问于 2021-01-31 09:47:25
回答 1查看 594关注 0票数 0

我已经在我的pc上安装了android studio,我也安装了flutter和Dart插件,但是当我运行"flutter run“时,我得到了这个错误,请帮助我

这就是错误

PS C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp> flutter使用硬件渲染与device sdk gphone x86 arm一起运行。如果您注意到图形伪像,请考虑使用"--enable- software - rendering“启用软件渲染。正在以调试模式启动sdk gphone x86 arm上的lib\main.dart ...正在运行Gradle任务“assembleDebug”...正在运行Gradle任务“assembleDebug”...完成28.0s√构建构建\app\outputs\flutter apk\app-debug.apk。cmd:找不到服务:活动安装build\app\output\flutter apk\app.apk...1.8s错误: ADB已退出,退出代码为%1,正在执行流安装

adb:无法安装C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp\build\app\outputs\flutter-apk\app.apk:命令:找不到服务:在sdk gphone x86 arm上启动应用程序时出现包错误。

windows 10操作系统

EN

回答 1

Stack Overflow用户

发布于 2021-01-31 11:13:51

运行以下命令:

代码语言:javascript
复制
flutter doctor -v

如果一切看起来都很好,那么就意味着这是一个配置问题。检查你的android清单,确保你已经为你的MainActivity设置了正确的意图过滤器。它需要一个main intent filter,以便启动应用程序。

还请确保您已遵循flutter文档中的所有要点,并在windows计算机上设置flutter:

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

然后检查您的build.gradle文件(在应用程序模块上),并确保它如下所示:

代码语言:javascript
复制
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许可证。如果有任何问题,颤动医生会告诉你的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65974998

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档