I have a problem : `A problem occurred evaluating...
# community-support
h
I have a problem :
A problem occurred evaluating project ':app'.
> Plugin with id 'com.android.application' not found.
The error line in my app/build.gradle :
Copy code
apply plugin: 'com.android.application'
In my android/build.gradle, i have:
Copy code
buildscript {
        ext.kotlin_version = '1.7.20'
        repositories {
            google()
            mavenCentral()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:8.5.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.4.2'
        }
    }
In my gradle-wrapper.properties, i have:
Copy code
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
Any help would be greatly appreciated (Im very new to gradle and mobile development
v
You add the AGP to the build script classpath of
android/build.gradle
, but you try to use it in
app/build.gradle
. There it thus is not available. But you should anyway avoid using the discouraged legacy way to apply plugins using
apply plugin
and instead use the
plugins { ... }
block, then you also do not need to use the
buildscript { ... }
block to add plugins to the buildscript classpath. I also highly recommend switching to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and an amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.
h
I am unable to change to Kotlin DSL right now as its another person's project and they just want to update the app to the latest api version and android version but i face the issue when i update it to gradle 8.5. does changing
buildscript { ... }
block to
apply plugin
and
plugins { ... }
block, fix the issue?
v
Not
buildscript
to
apply
and
plugins
, but
buildscript
and
apply
to
plugins
. And probably it will.
h
For my app/build.gradle:
Copy code
plugins {
    id 'com.android.application' version '8.6.0' apply false  // Same as the version in the android/build.gradle
    id 'com.android.library' version '8.6.0' apply false
    id 'kotlin-android' version '1.7.20'          // Same as the kotlin_version
    id 'com.google.gms.google-services' version '4.4.2' // Same as the version in the android/build.gradle
}
In my android/build.gradle, I removed the classpaths
Copy code
buildscript {
    ext.kotlin_version = '1.7.20'
    repositories {
        google()
        mavenCentral()
    }
}
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
My error is :
Copy code
* What went wrong:
Plugin [id: 'com.android.application', version: '8.6.0', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.6.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository
Im running Gradle 8.7 in the gradle-wrapper-properties:
Copy code
distributionUrl = https\://services.gradle.org/distributions/gradle-8.7-bin.zip
v
You do not have specified
google()
as plugin repository in your settings script