Проблемы с добавлением пакетов после перехода на версию плагина DSL.Android

Форум для тех, кто программирует под Android
Ответить
Гость
 Проблемы с добавлением пакетов после перехода на версию плагина DSL.

Сообщение Гость »

Недавно я обновился до версии flutter 3.19, в результате чего меня попросили изменить градиент на использование плагина dsl[https://docs.flutter.dev/release/breaki ... ugin-apply]. Однако я пытаюсь добавить в свой проект пакет flutter_local_notifications, в котором указано, что необходимо внести изменения в файл build.gradles. Я предлагаю добавить «com.android.tools», как указано в документации, следующим образом:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
}

Мои файлы Gradle:
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 'com.android.tools' version "7.3.1" apply false
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 "1.7.10" apply false
id 'com.google.gms.google-services' version "4.3.15" apply false
}

include ":app"

android/build.gradle:
ext {
compileSdkVersion = 34 // or higher / as desired
targetSdkVersion = 33 // or higher / as desired
minSdkVersion = 21 // Required minimum
appCompatVersion = "1.4.2" // or higher / as desired
playServicesLocationVersion = "21.0.1" // or higher / as desired
}

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"
id 'com.android.tools'
}

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 {
compileSdkVersion rootProject.ext.compileSdkVersion

ndkVersion flutter.ndkVersion

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

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

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true

}

signingConfigs {
release {

}
}
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.release
shrinkResources false
}
}
}

flutter {
source '../..'
}

dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
implementation 'io.radar:sdk:3.8.+'
implementation 'com.facebook.android:facebook-android-sdk:latest.release'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"

}

Однако упомянутые шаги соответствуют старой системе Gradle. У меня возникла проблема с добавлением плагина. Однако я попробовал внести изменения по методу плагина dsl. Я получаю сообщение об ошибке:
FAILURE: Build failed with an exception.

* Where:
Settings file '/StudioProjects/project/android/settings.gradle' line: 33

* What went wrong:
Plugin [id: 'com.android.tools', version: '7.3.1', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.tools:com.android.tools.gradle.plugin:7.3.1')
Searched in the following repositories:
Google
MavenRepo
Gradle Central Plugin Repository

* 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 1s
Error: Gradle task assembleDebug failed with exit code 1


Источник: https://stackoverflow.com/questions/781 ... -dsl-grade
Ответить

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

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

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

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

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