Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/syafiyft/StudioProjects/wild_watch_v2/android/build.gradle' line: 21
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method classpath() for arguments [com.android.tools.build:gradle:8.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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 9s
Error: Gradle task assembleDebug failed with exit code 1
I ran this with Xcode ios simulator and it ran just fine but when i want to use the android it shows these gradle error.
What does the mentioned build file look like?
You probably have
dependencies {
classpath('com.android.tools.build:gradle:8.3.0')
}
instead of
buildscript {
dependencies {
classpath('com.android.tools.build:gradle:8.3.0')
}
}
But even that you should not use, but use the plugins { ... }
block to apply plugins instead, then you do not need to add them to the buildscript
classpath
manually.
Besides that, I 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 amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.