Flutter应用程式正在Android模拟器上执行,但未在实体装置(OnePlus 7T)上执行 [英] Flutter app is running on Android Emulator but not on Physical Device (OnePlus 7T)

查看:47
本文介绍了Flutter应用程式正在Android模拟器上执行,但未在实体装置(OnePlus 7T)上执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Android Emulator上运行flutter应用程序时,它运行时没有错误,但是当我在移动设备上运行它时,它在调试控制台中显示了以下错误:

When I run my flutter app on Android Emulator it runs without errors but when I am running it on my mobile device it shows following error in Debug Console:

以调试模式在HD1901上启动lib \ main.dart ...失败:构建失败,并出现异常.

Launching lib\main.dart on HD1901 in debug mode... FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Failed to transform artifact 'arm64_v8a_debug.jar (io.flutter:arm64_v8a_debug:1.0.0-af51afceb8886cc11e25047523c4e0c7e1f5d408)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

      > Execution failed for JetifyTransform: C:\Users\Bharat\.gradle\caches\modules-2\files-2.1\io.flutter\arm64_v8a_debug\1.0.0-af51afceb8886cc11e25047523c4e0c7e1f5d408\b829535c84919575c5e7bfe4ebb08763a01eceec\arm64_v8a_debug-1.0.0-af51afceb8886cc11e25047523c4e0c7e1f5d408.jar.

         > Failed to transform 'C:\Users\Bharat\.gradle\caches\modules-2\files-2.1\io.flutter\arm64_v8a_debug\1.0.0-af51afceb8886cc11e25047523c4e0c7e1f5d408\b829535c84919575c5e7bfe4ebb08763a01eceec\arm64_v8a_debug-1.0.0-af51afceb8886cc11e25047523c4e0c7e1f5d408.jar' using Jetifier. Reason: invalid entry size (expected 27494264 but got 27496386 bytes). (Run with --stacktrace for more details.)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 48s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

已连接设备的"flutter doctor -v"的输出:

Output for 'flutter doctor -v' with device connected:

[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.720], locale en-IN)
    • Flutter version 1.12.13+hotfix.9 at C:\src\flutter
    • Framework revision f139b11009 (4 days ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\Bharat\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\Bharat\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 43.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.43.2)
    • VS Code at C:\Users\Bharat\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.8.1

[√] Connected device (1 available)
    • HD1901 • 90801aca • android-arm64 • Android 10 (API 29)

• No issues found!

应用程序级别"build.gradle"文件的内容:

App level 'build.gradle' file's content:

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

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

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

android {
    compileSdkVersion 28

    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.example.bbayshop_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

项目级别的"build.gradle"文件的内容:

Project level 'build.gradle' file's content:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

还包括"gradle-wrapper.properties"文件的内容:

Also including 'gradle-wrapper.properties' file's content:

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

推荐答案

已解决,只需删除C:\ Users \ .gradle \中".gradle"文件夹中的所有内容即可.如果显示文件已打开并且无法删除,则只需打开任务管理器,转到详细信息"选项卡并找到"java.exe"右键单击每个"java.exe",然后单击结束进程树".所有java.exe进程结束后,返回".gradle"文件夹并删除所有内容.就是这样.:)

Solved, just delete all the contents in the ".gradle" folder located in C:\Users\.gradle\ If it shows that the files are open and can't be deleted, just open Task Manager, go to Details tab and locate 'java.exe' Right click on each 'java.exe' and click End process tree. After all the java.exe processes are ended, go back to ".gradle" folder and delete all the contents. That's it. :)

这篇关于Flutter应用程式正在Android模拟器上执行,但未在实体装置(OnePlus 7T)上执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆