繁体   English   中英

flutter 错误:任务“:flutter_inappwebview:compileDebugJavaWithJavac”执行失败

[英]flutter error: Execution failed for task ':flutter_inappwebview:compileDebugJavaWithJavac'

当我要在我的移动设备上安装我的项目时,我收到了 chenge compileSDKVersion 33 的错误。

从 compileSDKVersion 32 更改我的 compileSDKVersion 33 后,我收到此错误 Execution failed for task ':flutter_inappwebview:compileDebugJavaWithJavac'。

这是我的 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"
apply plugin: 'com.google.gms.google-services'

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 33

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    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 "org.mycwc"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.facebook.android:facebook-login:latest.release'
    implementation 'com.facebook.android:facebook-android-sdk:latest.release'

}

从 compileSDKVersion 32 更改 compileSDKVersion 33 后出现此错误。

C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:280: error: cannot find symbol
      settings.setAppCachePath(options.appCachePath);
              ^
  symbol:   method setAppCachePath(String)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:494: error: cannot find symbol
      settings.setAppCacheEnabled(false);
              ^
  symbol:   method setAppCacheEnabled(boolean)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:504: error: cannot find symbol
      settings.setAppCacheEnabled(true);
              ^
  symbol:   method setAppCacheEnabled(boolean)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:515: error: cannot find symbol
        settings.setAppCachePath(ctx.getCacheDir().getAbsolutePath());
                ^
  symbol:   method setAppCachePath(String)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:517: error: cannot find symbol
        settings.setAppCacheEnabled(true);
                ^
  symbol:   method setAppCacheEnabled(boolean)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:521: error: cannot find symbol
      settings.setAppCacheEnabled(false);
              ^
  symbol:   method setAppCacheEnabled(boolean)
  location: variable settings of type WebSettings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.4.3+7\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:767: error: cannot find symbol
      settings.setAppCachePath(newOptions.appCachePath);
              ^
  symbol:   method setAppCachePath(String)
  location: variable settings of type WebSettings
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_inappwebview: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 5m 2s
Exception: Gradle task assembleDebug failed with exit code 1

同样的问题,我尝试了这些命令flutter clean flutter pub upgrade flutter pub get但仍然无法正常工作

  • 我解决了这个问题:
  1. 将我的 gradle 版本升级到7.1.4

  2. 将 gradle 包装器升级到7.4

  3. 升级kotlin版本到1.6.10

参考: https://github.com/pichillilorenzo/flutter_inappwebview/issues/1299#issuecomment-1240159079

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM