Не удалось найти метод kotlinOptions() для аргументов [...] расширения «android» типа com.android.build.gradle.LibraryExAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Не удалось найти метод kotlinOptions() для аргументов [...] расширения «android» типа com.android.build.gradle.LibraryEx

Сообщение Anonymous »

У меня возникла ошибка при создании пакета приложений для проекта во Flutter. Всякий раз при сборке у меня возникает эта ошибка:

Код: Выделить всё

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/JP/.pub-cache/hosted/pub.dev/firebase_core-2.27.0/android/build.gradle' line: 55

* What went wrong:
A problem occurred evaluating project ':firebase_core'.
> Could not find method kotlinOptions() for arguments [build_cn7tqacxu2xc1m49ym5jhj2ab$_run_closure1$_closure7@35e21027] on extension 'android' of type com.android.build.gradle.LibraryExtension.

* 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 19s
Running Gradle task 'bundleRelease'...                             19.7s
Gradle task bundleRelease failed with exit code 1
Я несколько раз пытался настроить ff. файлы, и я застрял в бесконечном цикле ошибок:
  • android/build.gradle:

Код: Выделить всё

buildscript {
ext.kotlin_version = '2.0.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.gms:google-services:4.3.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
  • android/app/build.gradle:

Код: Выделить всё

plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

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

android {
namespace "com.hmc.mobileapps.mosaic.prestige"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

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 "com.hmc.mobileapps.mosaic.prestige"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

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

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// FCM Fallback Delivery
implementation 'com.google.firebase:firebase-messaging:23.2.1'
}
  • gradle-wrapper.properties:

Код: Выделить всё

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
  • settings.gradle:

Код: Выделить всё

pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.0"  apply false
}

include ":app"
От доктора флаттера --verbose:

Код: Выделить всё

[✓] Flutter (Channel stable, 3.24.5, on macOS 13.7.1 22H221 darwin-x64, locale en-PH)
• Flutter version 3.24.5 on channel stable at /Users/JP/_SDK/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision dec2ee5c1f (5 weeks ago), 2024-11-13 11:13:06 -0800
• Engine revision a18df97ca5
• Dart version 3.5.4
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/JP/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/JP/Library/Android/sdk
• Java binary at: /Users/JP/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
• Android Studio at /Users/JP/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.4)
• IntelliJ at /Users/JP/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Community Edition (version 2024.2.1)
• IntelliJ at /Users/JP/Applications/IntelliJ IDEA Community Edition.app
• Flutter plugin version 83.0.3
• Dart plugin version 242.24931

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.4)
• IntelliJ at /Users/JP/Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.94.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
• iPhone 15 Pro Max (mobile) • A74F75E8-D685-4AE8-A990-8495C15EF811 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
• macOS (desktop)            • macos                                • darwin-x64     • macOS 13.7.1 22H221 darwin-x64
• Chrome (web)               • chrome                               • web-javascript • Google Chrome 131.0.6778.140

[✓] Network resources
• All expected network resources are available.

• No issues found!
Не знаю, не упускаю ли я что-нибудь еще. Я также пытался запросить AI, но не получил правильного решения. Пожалуйста, помогите.

Подробнее здесь: https://stackoverflow.com/questions/792 ... on-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»