当前位置: 首页 > 知识库问答 >
问题:

flutter:failure:生成失败,出现异常

邢寒
2023-03-14
`
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\hp\AndroidStudioProjects\youtubeclone\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.


* 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 1m 45s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker...

C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:20: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:38: error: cannot find symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FilePickerPlugin
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:45: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:49: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:53: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:57: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:61: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:66: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:277: error: cannot find symbol
            this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                             ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FilePickerPlugin
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:278: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.addObserver(this.observer);
                                           ^
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\file_picker-2.1.0\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:287: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.removeObserver(this.observer);
                                              ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for 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 11s

Exception: The plugin file_picker could not be built due to the issue above.
`
`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.zaidounmohamed.youtubeclone"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

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

`

这是我的密码

`import 'package:dio/dio.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:path/path.dart';

class CustomFilePicker extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _CustomFilePicker();
  }
}

class _CustomFilePicker extends State<CustomFilePicker> {
  FilePickerResult selectedfile;
  Response response;
  String progress;
  Dio dio = new Dio();

  selectFile() async {
    selectedfile = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['jpg', 'pdf', 'mp4', 'doc'],
      //allowed extension to choose
    );
    setState(() {}); //update the UI so that file name is shown
  }

  uploadFile() async {
    String uploadurl = "http://192.168.0.112/test/file_upload.php";
    //dont use http://localhost , because emulator don't get that address
    //insted use your local IP address or use live URL
    //hit "ipconfig" in windows or "ip a" in linux to get you local IP

    FormData formdata = FormData.fromMap({
      "file": await MultipartFile.fromFile(selectedfile.paths.toString(),
          filename: basename(selectedfile.paths.toString())
          //show only filename from path
          ),
    });

    response = await dio.post(
      uploadurl,
      data: formdata,
      onSendProgress: (int sent, int total) {
        String percentage = (sent / total * 100).toStringAsFixed(2);
        setState(() {
          progress = "$sent" +
              " Bytes of " "$total Bytes - " +
              percentage +
              " % uploaded";
          //update the progress
        });
      },
    );

    if (response.statusCode == 200) {
      print(response.toString());
      //print response from server
    } else {
      print("Error during connection to server.");
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Select File and Upload"),
          backgroundColor: Colors.orangeAccent,
        ), //set appbar
        body: Container(
            alignment: Alignment.center,
            padding: EdgeInsets.all(40),
            child: Column(
              children: <Widget>[
                Container(
                  margin: EdgeInsets.all(10),
                  //show file name here
                  child: progress == null
                      ? Text("Progress: 0%")
                      : Text(
                          basename("Progress: $progress"),
                          textAlign: TextAlign.center,
                          style: TextStyle(fontSize: 18),
                        ),
                  //show progress status here
                ),

                Container(
                  margin: EdgeInsets.all(10),
                  //show file name here
                  child: selectedfile == null
                      ? Text("Choose File")
                      : Text(basename(selectedfile.paths.toString())),
                  //basename is from path package, to get filename from path
                  //check if file is selected, if yes then show file name
                ),

                Container(
                    child: RaisedButton.icon(
                  onPressed: () {
                    selectFile();
                  },
                  icon: Icon(Icons.folder_open),
                  label: Text("CHOOSE FILE"),
                  color: Colors.redAccent,
                  colorBrightness: Brightness.dark,
                )),

                //if selectedfile is null then show empty container
                //if file is selected then show upload button
                selectedfile == null
                    ? Container()
                    : Container(
                        child: RaisedButton.icon(
                        onPressed: () {
                          uploadFile();
                        },
                        icon: Icon(Icons.folder_open),
                        label: Text("UPLOAD FILE"),
                        color: Colors.redAccent,
                        colorBrightness: Brightness.dark,
                      ))
              ],
            )));
  }
}`

共有1个答案

黄仲渊
2023-03-14

示例:classpath“com.android.tools.build:gradle:4.0.0”

转到android>gradle>gradle-wrapper.properties文件并升级分发URL。

示例:distributionurl=https\:/services.gradle.org/distributions/gradle-6.1.0-all.zip

 类似资料:
  • 当我运行时,我的构建失败了,我收到了以下消息: 失败:生成失败,出现异常。 > 错误:配置根项目“RxRedux”时出现问题。 无法解析配置“:classpath”的所有文件。找不到com。Android工具。构建:gradle:3.0。1.在以下位置搜索:https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle

  • AGPBI:{“kind”:“error”,“text”:“Android资源链接失败”,“sources”:[{}],“original”:“error::AAPT:D:\Android basics kotlin cupcake app starter\app\build\intermediates\processed\u res\debug\out\resources-debug.ap\:错

  • 我的项目中出现了以下错误:`Failure:生成失败,出现异常。 > 其中:设置文件'/home/kaizar/music/oreo-fashion-v2.3.0/app/rn_oreo/android/Settings.gradle'行:4 错误:评估设置“rn_oreo”时出现问题。 请访问https://help.gradle.org获取更多帮助

  • 最近我在eclipse上建立了一个Minecraft Forge工作区。我在过去用forge(MC1.6.4等等)创建了minecraft MOD,尽管从那以后有了很大的变化。我正在尝试使用Forge1.15.2-31.1.0 mdk和JDK 1.8.0_241进行修改 我创建了一个RunClient。bat文件,用于编译和构建我的项目 它完全编译到98%,然后崩溃。这是我的事故报告: --UPD

  • 当我尝试时,我出现了以下错误…有人能帮忙吗? 失败:生成失败,出现异常。 null 请访问https://help.gradle.org获取更多帮助 生成在12s运行分级任务“汇编发布”时失败...正在运行分级任务“汇编发布”...已完成13.3s分级任务AssemblereRease失败,退出代码为%1