简体   繁体   English

Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T)

[英]Flutter app is running on Android Emulator but not on Physical Device (OnePlus 7T)

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:当我在 Android 模拟器上运行我的 flutter 应用程序时,它运行时没有错误,但是当我在移动设备上运行它时,它在调试控制台中显示以下错误:

Launching lib\main.dart on HD1901 in debug mode... FAILURE: Build failed with an exception.以调试模式在 HD1901 上启动 lib\main.dart... 失败:构建失败并出现异常。

* 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)

Output for 'flutter doctor -v' with device connected: Output 用于连接设备的“颤振医生 -v”:

[√] 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!

App level 'build.gradle' file's content:应用级“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 = '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'
}

Project level 'build.gradle' file's content:项目级“build.gradle”文件的内容:

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
}

Also including 'gradle-wrapper.properties' file's content:还包括“gradle-wrapper.properties”文件的内容:

#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

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.解决了,把C:\Users\.gradle\中的“.gradle”文件夹中的内容全部删除,如果显示文件已打开,无法删除,打开任务管理器,go到Details选项卡,找到'java.exe' 右键单击每个'java.exe',然后单击结束进程树。 After all the java.exe processes are ended, go back to ".gradle" folder and delete all the contents.在所有java.exe进程结束后,go回到“.gradle”文件夹并删除所有内容。 That's it.而已。 :) :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter 应用程序在 android 工作室模拟器上完美运行,但 go 无法通过物理设备上的加载屏幕 - Flutter app runs perfectly on android studio emulator but doesn't go past the loading screen on physical device 仅在物理设备而非模拟器上运行 Android 应用 - Run Android app Only on Physical Device not Emulator 无法在 Android 模拟器或 Android 物理设备中运行 Flutter 项目 - Not able to run Flutter Project in Android Emulator or Android Physical Device 无法在 iOS 仿真器或物理设备上构建 Flutter 应用程序 - 虽然在 Android 上工作正常 - Cannot build Flutter app on iOS emulator or physical device - works fine on Android though Flutter 应用程序在模拟器(Pixel 4)上呈现良好,但在物理设备上溢出 - Flutter app renders fine on the emulator (Pixel 4) but overflows on physical device Android App 在模拟器中运行良好,但无法在真实设备中安装 - Android App running fine in Emulator but can't install in real device 在实体android错误上运行flutter应用程序 - Running flutter app on physical android error 在 Android 模拟器和物理设备中运行程序之间的区别? - Difference between running a program in Android emulator and physical device? 与模拟器不同,Android 应用程序 UI 无法在物理设备上正确显示 - Android app UI isn't displaying properly on physical device, unlike emulator 在物理Android设备上运行Meteor移动应用 - Running Meteor mobile app on physical Android device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM