任务“:share_plus:compileDebugKotlin”执行失败。获取这个编译 flutter 应用程序尝试了所有 flutter clean 等,但没有任何效果

Ars*_*han 7 flutter flutter-dependencies

注意:某些输入文件使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以了解详细信息。注意:某些输入文件使用未经检查或不安全的操作。注意:使用 -Xlint:unchecked 重新编译以了解详细信息。注意:C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\launch_review-3.0.1\android\src\main\java\com\iyaffle\launchreview\LaunchReviewPlugin.java 使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以了解详细信息。注意:C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\path_provider_android-2.0.12\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java使用未经检查或不安全的操作。注意:使用 -Xlint:unchecked 重新编译以了解详细信息。e: C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\share_plus-3.1.0\android\src\main\kotlin\dev\fluttercommunity\plus\share\MethodCallHandler.kt : (34, 24): 类型不匹配:推断类型是 String?但预期是字符串

失败:构建失败并出现异常。

  • 出了什么问题:任务“:share_plus:compileDebugKotlin”执行失败。

编译错误。查看日志了解更多详情

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • 在https://help.gradle.org获取更多帮助

48 秒内构建失败异常:Gradle 任务 assembleDebug 失败,退出代码为 1

获取这个编译 flutter 应用程序尝试了所有 flutter clean 等,但没有任何效果。

Car*_*nda 9

我今天也遇到了同样的问题。

对我来说唯一的解决方案是这个。

  1. 去你的pubspec.yaml
  2. 删除您的share_plus行,然后放入 share_plus: ^4.0.4(或来自 pub.dev 的最新版本
  3. Ctrl+S
  4. flutter run
  5. 享受


小智 0

我昨天也遇到了同样的问题,虽然我不太记得我是如何解决的。让我们尝试一下这个标准:

\n
    \n
  1. 擦除所有 flutter 缓存(flutter clean)并升级到最新的 flutter 和 dart。
  2. \n
  3. 将您的插件更新到最新版本。
  4. \n
  5. 我将在下面给你我的 android/build.gradle 文件,进行比较。
  6. \n
  7. 我还将向您展示我的 android/app/build.gradle 文件,查找编写 kotlin 的行、其版本、导入等。
  8. \n
\n

我不会\xe2\x80\x99t说,但据我记得,我在使用其中一个翻译插件时遇到了这个问题,这个插件向String对象添加了一个额外的翻译方法,它在代码中正确显示,但启动时出现了与 Kotlin 相关的错误。示例:\n
字符串文本;\n
\nprint(text.translate); // 没有明显原因的错误\n

因此请仔细检查您的代码。\n

请特别注意错误消息中的警告:“类型不匹配:推断类型是 String?但需要 String”。尝试在新编写的功能中找到这个差距。

\n

安卓/build.gradle:

\n
buildscript {\n    ext.kotlin_version = '1.6.10'\n    repositories {\n        google()\n        mavenCentral()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:4.1.0'\n        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n    }\n\n    // gradle.projectsEvaluated {\n    //     tasks.withType(JavaCompile){\n    //         options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"\n    //     }\n    // }\n}\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n}\n\nrootProject.buildDir = '../build'\nsubprojects {\n    project.buildDir = "${rootProject.buildDir}/${project.name}"\n}\nsubprojects {\n    project.evaluationDependsOn(':app')\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n
Run Code Online (Sandbox Code Playgroud)\n

android/app/build.gradle:

\n
def localProperties = new Properties()\ndef localPropertiesFile = rootProject.file('local.properties')\nif (localPropertiesFile.exists()) {\n    localPropertiesFile.withReader('UTF-8') { reader ->\n        localProperties.load(reader)\n    }\n}\n\ndef flutterRoot = localProperties.getProperty('flutter.sdk')\nif (flutterRoot == null) {\n    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")\n}\n\ndef flutterVersionCode = localProperties.getProperty('flutter.versionCode')\nif (flutterVersionCode == null) {\n    flutterVersionCode = '1'\n}\n\ndef flutterVersionName = localProperties.getProperty('flutter.versionName')\nif (flutterVersionName == null) {\n    flutterVersionName = '1.0'\n}\n\napply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"\n\nandroid {\n    compileSdkVersion flutter.compileSdkVersion\n\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n\n    kotlinOptions {\n        jvmTarget = '1.8'\n    }\n\n    sourceSets {\n        main.java.srcDirs += 'src/main/kotlin'\n    }\n\n    defaultConfig {\n        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).\n        applicationId "com.example.legend_application"\n        minSdkVersion 22 //flutter.minSdkVersion\n        targetSdkVersion flutter.targetSdkVersion\n        versionCode flutterVersionCode.toInteger()\n        versionName flutterVersionName\n\n        multiDexEnabled true\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled true\n            shrinkResources true\n            // TODO: Add your own signing config for the release build.\n            // Signing with the debug keys for now, so `flutter run --release` works.\n            signingConfig signingConfigs.debug\n        }\n    }\n}\n\nflutter {\n    source '../..'\n}\n\ndependencies {\n    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"\n    implementation 'com.android.support:multidex:1.0.3'\n}\n
Run Code Online (Sandbox Code Playgroud)\n