任务“: permission_handler:compileDebugJavaWithJavac”的执行失败。 FLUTTER

4

我刚接触Flutter,现在遇到了一些错误。当我使用

compileSdkVersion 30

出现了这个错误

Execution failed for task ':geolocator_android:compileDebugJavaWithJavac'

当我使用时

compileSdkVersion 31

之前的错误已经消失,我们得到了这个错误

Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.

Launching lib\main.dart on SM A515F in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

Parameter format not correct -

Note: C:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-11.2.4\android\src\main\java\io\flutter\plugins\firebase\messaging\JobIntentService.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\geocoding-2.0.1\android\src\main\java\com\baseflow\geocoding\GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-6.1.3\android
\src\main\java\com\baseflow\permissionhandler\ServiceManager.java:152: 
warning: [deprecation] getDefaultAdapter() in BluetoothAdapter has been deprecated
        final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
                                                                  ^

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.
> 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 4m 49s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)


你能分享一下你的控制台日志数据吗? - Diwyansh
我该怎么做? - Muhammad Shafique
如果您在项目中使用了权限处理程序,则Geolocator存在一些版本问题,您需要降级您的Geolocator版本并进行同步。 - Jahidul Islam
这是我没有使用 permission_handler 的问题。 - Muhammad Shafique
在您的控制台中复制所有文本并将其粘贴到您的问题中。 - Diwyansh
请检查一下,我已经更新了。 - Muhammad Shafique
2个回答

1

使用应用程序 -> 构建 Gradle


minSdkVersion 21 targetSdkVersion 31


android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.eos.asd"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 2
        versionName '1.02'
    }

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

仍然存在相同的问题。 - Muhammad Shafique
minSdkVersion 设置为 28 对我有用。 - ego

0

升级构建工具版本

buildscript {
    repositories {...}

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1' //<-- Make this atleast 4.2.1
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接