Could not determine the dependencies of task Could not create task - java

I want to install the gradle plugin version 7.6
but I get this Error :
Could not determine the dependencies of task ':path_provider_android:test'.
Could not create task ':path_provider_android:testProfileUnitTest'.
this and base files have different roots: E:\flutter downloader the main program\flutterdownloaderthemainprogram\build\path_provider_android and C:\Users\Gcc\Downloads\Compressed\flutter_windows_3.3.0-stable\flutter.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.22\android.
this is the build.gradle:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
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')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I use the java19
I try java17 and java11
I tried diffrent version of the gradle but I get the same Error

-go to the project terminal (ctrl+j in vscode) and run flutter clean
-go to the android folder and delete the .gradle folder
-run flutter pub get
-run flutter run

Related

Gradle Issues in Android Studio

There's a Java file I'm meant to convert to Kotlin. I'm stuck with this Gradle problem and can't find my way around it. What can I do to resolve this issue?
Go to build.gradle(Module)
and inside dependencies add the following line.
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
It should look something like this
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Could not resolve in adding HMS Huawei repos in gradle

im trying to integrate in HMS Huawei, in adding classpath im have error:
Could not resolve com.huawei.agconnect:agcp:1.6.0.300.
my build.gradle:
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}
allprojects {
repositories {
google()
jcenter()
repositories {
maven { url 'http://dl.bintray.com/swallowsonny/ext/' }
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
}
}
}
my gradle ver: 6.7.1 and gradle plugin ver: 4.1.3
Try this:
Go to File -> Project Settings -> Gradle and uncheck the Gradle offline work option.
Synchronize the project again and let all the dependencies get downloaded.
I have corrected settings.gradle like this:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven {url 'https://developer.huawei.com/repo/'} // add this line
}
}

Android Studio build gradle failded

I have recently downloaded Android studio version 3.6.3 . When I create a new project I get these errors:
Could not resolve all artifacts for configuration 'classpath'
Could not resolve com.android.tools.build:gradle:5.6.4.
No cached version of com.android.tools.build:gradle:5.6.4. available for offline mode.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:5.6.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
How should I solve this?
You are confusing the gradle version and the gradle plugin version:
The gradle plugin 5.6.4 doesn't exist.
Use:
classpath 'com.android.tools.build:gradle:3.6.3'
The version of gradle is defined in the gradle/wrapper/gradle-wrapper.properties file:
distributionUrl = https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Build Failing: org.codehaus.groovy.control.MultipleCompilationErrorsException

I recently added Kotlin to my Java project, my build started failing, and I am getting this message:
"only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed" and this "Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:"
Does anyone have any idea how to fix this? I have my jdk set as 1.8 (as you see below), so the existing answer to this question does not seem to apply.
compileOptions {
sourceCompatibility '1.8'
targetCompatibility '1.8'
}
As for the brackets, here's my project build.gradle file where it's referencing.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
}
I guess I'm at the bleary eyed stage of the day. I moved it before allprojects and it worked. This was helpful:
only build script and other plugins script blocks are allowed before plugins

Android studio error:Error:(23, 0) Could not find method android() for arguments on root project

I reinstalled android studio, I am using the same project with android studio in another PC so the code is probably fine!
It is the full error:
Error:(23, 0) Could not find method android() for arguments [build_1z9k6ruj47plglocgqknjnoag$_run_closure3#133cf914] on root project 'allthingsvegan-android-9d296805dc64' of type org.gradle.api.Project.
Open File
The solutions I've found on the internet was including changing the code.. So they are not relevant to me
Thanks!!
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
buildToolsVersion '24.0.1'
}
It is the top-level build.gradle file.
In this file you can't use this block:
android {
buildToolsVersion '24.0.1'
}
Remove this block.
you need to apply the android plugin:
apply plugin: 'com.android.application'
this needs to be done after buildscript like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
buildToolsVersion '24.0.1'
}
uncomment android tag present in build.gradle(Project:android-start)
rebuild the gradle it asks to update .
Update the gradle then sync it works

Categories

Resources