我已经在我的电脑上安装了 android studio,我还安装了 flutter 和 Dart 插件,但是当我运行“flutter run”时出现这个错误,请帮帮我
这是错误
PS C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp> 颤动运行 使用设备 sdk gphone x86 arm 的硬件渲染。如果您注意到图形伪像,请考虑启用软件渲染 “--启用软件渲染”。 在调试模式下在 sdk gphone x86 arm 上启动 lib\main.dart... 正在运行 Gradle 任务“assembleDebug”... 运行 Gradle 任务 'assembleDebug'... 完成 28.0s √ 内置 build\app\outputs\flutter-apk\app-debug.apk。 cmd:找不到服务:活动 安装 build\app\outputs\flutter-apk\app.apk... 1.8s 错误:ADB 退出,退出代码为 1 执行流式安装
adb: 安装失败 C:\Users\Ebenezer Essoun\Desktop\Srrc\workApp\build\app\outputs\flutter-apk\app.apk: cmd: Can't find service: package 在 sdk gphone x86 arm 上启动应用程序时出错。
Windows 10 操作系统
答案 0 :(得分:0)
运行命令:
flutter doctor -v
如果一切正常,则说明是配置问题。检查您的 android 清单,并确保您已使用正确的意图过滤器设置了 MainActivity。它需要一个主意图过滤器,以便启动应用程序。
还请确保您已遵循 Flutter 文档中的所有要点,并在 Windows 机器上设置 Flutter:
https://flutter.dev/docs/get-started/install/windows
然后检查您的 build.gradle 文件(在 app 模块上)并确保它看起来像这样:
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医生会告诉你的。