Android Studio - 任务 ':app:compileDebugKotlin' 的执行失败 - 无法转换工件 'x86_debug.jar



我已经遵循了本页中的所有说明:https://flutter.dev/docs/get-started/install/windows

但当我试图运行"first_app"时,我会遇到一个错误:

Android Studio-运行first_app

main.dart

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

错误

Launching libmain.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
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 'x86_debug.jar (io.flutter:x86_debug:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:Usersm-err.gradlecachesmodules-2files-2.1io.flutterx86_debug1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0ce05f5680b1bbc2a38b625423c4ab890a526847ccx86_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar.
> Failed to transform 'C:Usersm-err.gradlecachesmodules-2files-2.1io.flutterx86_debug1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0ce05f5680b1bbc2a38b625423c4ab890a526847ccx86_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar' using Jetifier. Reason: invalid stored block lengths. (Run with --stacktrace for more details.)
> Failed to transform artifact 'x86_64_debug.jar (io.flutter:x86_64_debug:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:Usersm-err.gradlecachesmodules-2files-2.1io.flutterx86_64_debug1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c35b1d03b15670cc489efdcf317faf29bfd904402x86_64_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar.
> Failed to transform 'C:Usersm-err.gradlecachesmodules-2files-2.1io.flutterx86_64_debug1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c35b1d03b15670cc489efdcf317faf29bfd904402x86_64_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar' using Jetifier. Reason: invalid stored block lengths. (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 3s
Finished with error: Gradle task assembleDebug failed with exit code 1

扑动医生

Doctor summary (to see all details, run flutter doctor -v): 
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Versione 10.0.18362.720], locale it-IT)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.6)

build.gradle(android(*

buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
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
}

build.gradle(app/src(

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 29
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.first_app"
minSdkVersion 16
targetSdkVersion 29
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.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

渐变包装器。属性

#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.6.4-all.zip

测试

  1. 更新了kotlin版本
  2. flutter clean-->D:\开发\ flutter \first_app
  3. 更新后重新创建项目

LOGFILE

2020-04-01 15:38:00,597 [  96871]   INFO - rationStore.ComponentStoreImpl - Saving Project 'D:Developmentflutterfirst_app' first_appKotlin2JvmCompilerArguments took 11 ms 
2020-04-01 15:38:43,068 [ 139342]   INFO - .flutter.run.daemon.FlutterApp - RunApp first_app (Run) 
2020-04-01 15:38:43,068 [ 139342]   INFO - .flutter.run.daemon.FlutterApp - D:Programsflutterbinflutter.bat [--no-color, run, --machine, --track-widget-creation, --device-id=emulator-5554, libmain.dart] 
2020-04-01 15:38:58,491 [ 154765]   INFO - .FlutterAppDaemonEventListener - app shutdown took longer than 100ms 
2020-04-01 15:38:58,516 [ 154790]   INFO - .flutter.run.daemon.FlutterApp - StopApp first_app (Run) 
2020-04-01 15:38:58,958 [ 155232]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2020-04-01 15:38:59,037 [ 155311]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok 
2020-04-01 15:38:59,073 [ 155347]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 36ms; general responsiveness: ok; EDT responsiveness: ok 
2020-04-01 15:38:59,073 [ 155347]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 3 files to update 
2020-04-01 15:38:59,112 [ 155386]   INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 39ms; general responsiveness: ok; EDT responsiveness: ok 
2020-04-01 15:39:48,894 [ 205168]   WARN - n.process.BaseOSProcessHandler - Process hasn't generated any output for a long time.
If it's a long-running mostly idle daemon process, consider overriding OSProcessHandler#readerOptions with 'BaseOutputReader.Options.forMostlySilentProcess()' to reduce CPU usage.
Command line: D:ProgramsAndroidemulatoremulator.exe -netdelay none -netspeed full -avd Pixel_2_API_29 
java.lang.Throwable: Process creation:
at com.intellij.execution.process.BaseOSProcessHandler.<init>(BaseOSProcessHandler.java:33)
at com.android.tools.idea.avdmanager.EmulatorProcessHandler.<init>(EmulatorProcessHandler.java:45)
at com.android.tools.idea.avdmanager.EmulatorRunner.start(EmulatorRunner.java:57)
at com.android.tools.idea.avdmanager.AvdManagerConnection.startAvd(AvdManagerConnection.java:419)
at com.android.tools.idea.avdmanager.AvdManagerConnection.startAvd(AvdManagerConnection.java:358)
at com.android.tools.idea.avdmanager.RunAvdAction.actionPerformed(RunAvdAction.java:36)
at com.android.tools.idea.avdmanager.AvdUiAction.hyperlinkUpdate(AvdUiAction.java:127)
at com.intellij.ui.HyperlinkLabel.fireHyperlinkEvent(HyperlinkLabel.java:218)
at com.intellij.ui.HyperlinkLabel.processMouseEvent(HyperlinkLabel.java:141)
at java.awt.Component.processEvent(Component.java:6315)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4899)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:739)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:736)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:878)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:823)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2020-04-01 15:58:25,798 [1322072]   WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'Project' content in TODO tool window to avoid focus-related problems. 
2020-04-01 15:58:25,799 [1322073]   WARN - j.openapi.wm.impl.IdeFrameImpl - Project tool window - parent container is hidden 
2020-04-01 15:58:45,410 [1341684]   WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in '' content in Dart Analysis tool window to avoid focus-related problems. 
2020-04-01 15:58:45,410 [1341684]   WARN - j.openapi.wm.impl.IdeFrameImpl -  tool window - parent container is hidden 
2020-04-01 15:58:47,751 [1344025]   WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in '' content in Logcat tool window to avoid focus-related problems. 
2020-04-01 15:58:47,751 [1344025]   WARN - j.openapi.wm.impl.IdeFrameImpl -  tool window - parent container is hidden 
2020-04-01 15:58:47,837 [1344111]   INFO - AndroidLogcatToolWindowFactory - Successfully obtained debug bridge 
2020-04-01 15:58:59,615 [1355889]   INFO - m.pty4j.windows.WindowsVersion - Windows version: 10.0.18362 
2020-04-01 15:59:04,985 [1361259]   WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'Project' content in TODO tool window to avoid focus-related problems. 
2020-04-01 15:59:04,986 [1361260]   WARN - j.openapi.wm.impl.IdeFrameImpl - Project tool window - parent container is hidden 
2020-04-01 15:59:05,402 [1361676]   WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'main.dart' content in Run tool window to avoid focus-related problems. 
2020-04-01 15:59:05,402 [1361676]   WARN - j.openapi.wm.impl.IdeFrameImpl - main.dart tool window - parent container is hidden 
2020-04-01 15:59:12,685 [1368959]   WARN - com.intellij.util.xmlb.Binding - no accessors for class org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptInputsWatcher$Storage 
2020-04-01 15:59:12,693 [1368967]   WARN - com.intellij.util.xmlb.Binding - no accessors for class org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage 
2020-04-01 15:59:13,373 [1369647]   INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 734 ms 
2020-04-01 16:00:37,197 [1453471]   INFO - .flutter.run.daemon.FlutterApp - RunApp first_app (Run) 
2020-04-01 16:00:37,197 [1453471]   INFO - .flutter.run.daemon.FlutterApp - D:Programsflutterbinflutter.bat [--no-color, run, --machine, --track-widget-creation, --device-id=emulator-5554, libmain.dart] 
2020-04-01 16:00:43,092 [1459366]   INFO - .FlutterAppDaemonEventListener - app shutdown took longer than 100ms 
2020-04-01 16:00:43,121 [1459395]   INFO - .flutter.run.daemon.FlutterApp - StopApp first_app (Run) 

请帮帮我,我正在学习一门课程,但如果我不解决这个问题,我就无法继续。

\TIA-

我怀疑这是下载中断或转换中断的结果,因为错误消息invalid stored block lengths清楚地提示存在损坏的ZIP/JAR文件。请尝试清空目录C:Usersm-err.gradlecaches,然后重新生成应用程序。

并且不要禁用Lint检查,这样它就会抱怨最终的无效包:

lintOptions {
// disable 'InvalidPackage'
}

此外,当仅使用androidx依赖项时,不需要使用Jetifier。

最新更新