What should I do with "implementation method not found" error? [duplicate] - android

This question already has answers here:
Gradle DSL method not found: 'implementation()'
(9 answers)
How to fix "ERROR: Gradle DSL method not found" on Android Studio 3.3
(2 answers)
Closed 3 years ago.
I was working on a react native app and I installed react-navigation library and its dependencies. then after I tried to run my app using Android Studio I get this error:
ERROR: Gradle DSL method not found: 'implementation()'
Possible causes:
The project 'MealApp' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
I changed nothing and this error just poped up. What should I do to get rid of this annoying thing?

the implementation is support in the Gradle version after 3. try to change it in the android/build.gradle as the following
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
At the same time, change the gradle-wrapper.properties Gradle version
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

Related

Gradle 4.2.+ Could not resolve navigation-ui-ktx:2.3.5

After upgrading Android Studio to Fox version, Gradle from 4.1.3 to 7.0.0 or even 4.2.+, and distributionUrl to gradle-7.0.1-bin.zip, I couldn’t build my app anymore.
This is the error log:
* What went wrong:
Execution failed for task ':onboarding:dataBindingMergeDependencyArtifactsDebugMobDebug'.
> Could not resolve all files for configuration ':onboarding:debugMobDebugCompileClasspath'.
> Could not resolve android.arch.navigation:navigation-ui-ktx:2.3.5.
Required by:
project :onboarding
> Skipped due to earlier error
It seems Gradle couldn't download NavigationKTX version 2.3.5.
The solution is downgrading but
How to fix the issue without downgrading to Gradle version 4.1.+
I wanna use jetpack compose in my application so I need to update gradle to 4.2.+.
The current Gradle version for Arctic Fox is eg. gradle-7.1.1-all.zip (or bin).
AGP & SafeArgs:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// classpath "com.android.tools.build:gradle:4.2.2"
// classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
classpath "com.android.tools.build:gradle:7.0.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0-alpha02"
}
}
...
apply plugin: "androidx.navigation.safeargs.kotlin"
And the whole android.arch name-space had been superseded:
android.arch.navigation:navigation-ui-ktx:2.3.5
Use the current androidx name-space instead, where 2.3.5 is the latest stable version:
androidx.navigation:navigation-ui-ktx:2.3.5 / 2.4.0-alpha06
Be aware not to mix up these library name-spaces (there may be further conflicts) - or that enabling the Jetifier may be required, depending on further outdated dependencies (because name-space com.android.support had also been superseded by androidx). Unless a) updating the dependencies and b) fixing all imports ...this project won't build.

How to downgrade android gradle?

Since I update android gradle I have issues in my ringtone app, problem is in copying files and permissions I guess (I noticed that in manifest android.permission.WRITE_SETTINGS is underlined with red color, and I guess there is the problem)
Same code works perfectly in my old projects and the only difference is in gradle, so I tried some tutorials on net on how to downgrade it, but I have failed.
I tried in gradle-wrapper.properties(Gradle Version) to change
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
to the version that worked for me before, but I got message that 4.4 is minimum
then i tried to downgrade in build.gradle(Project)
but only succeeded to downgrade it to
classpath 'com.android.tools.build:gradle:3.0.1'
but that didn't solved my problem, because the working version was 2.3.3
with distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
and when I tried to sync with 2.3.3 i got error
Gradle DSL method not found: 'google()'
Possible causes:<ul><li>The project 'MyProject' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.1.4 and sync project</li><li>The project 'MyProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
Can somebody tell me the proper way and step by step solution to my problem
Below are the steps you may try but this is not a good way of solving the problem. You better focus on the main issue and try to solve it. Start from here or find other workarounds.
1-Remove google() from build.gradle and add maven instead:(for Gradle lower than 4.1)
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
2-Go to gradle-wrapper.properties and change gradle version to:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
3-Change gradle plugin to(if you're using Android Studio 2.x.x):
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
4-Sync.

Error:(8, 0) Gradle DSL method not found: 'compile()'

How can I resolve this problem?
At first the problem was, I would like to use ActivityCompat class for ask permission. After it shown me the AdroidStudio, the class cannot be resolved to a type but, the Support Repository already installed...
I upgraded the AndroidStudio to 2.3 from 2.2 after show me:
Error:(8, 0) Gradle DSL method not found: 'compile()'
Currently here are the possible solutions by Android Studio:
'Sensors' may be using a version of the Android Gradle plug-in that
does not contain the method (e.g. 'testCompile' was added in 1.1.0).
(Upgrade plugin to version 2.3.0 and sync project)
The project 'Sensors' may be using a version of Gradle that does not
contain the method. (Gradle settings)
The build file may be missing a Gradle plugin. (Apply Gradle plugin)
What is the right solution for this? I tried each but not resolve the problem.
Here is the dependencies of build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
compile "com.android.support:support-core-utils:25.2.0"
}
Move compile "com.android.support:support-core-utils:25.2.0" out of your top-level build.gradle file and into the module's build.gradle file (e.g., app/build.gradle) and its dependencies closure.

gradle project sync failed. basic functionality(e.g editing,debuggin) will not work properly

I am trying to import a project in android studio. After import when I try to sync it with Gradle it says Gradle Sync Failed. basic Functionality (e.g editing, debugging) will not work properly. Android Studio version is 1.5.1. Here is what build.gradle looks like for my module that I am trying to run:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath "com.squareup.retrofit:retrofit:1.2.2"
classpath "com.squareup.okhttp:okhttp:1.2.1"
}
}
When I try to update gradle version to 1.0.0. It says:
The Project is using an unsupported version of Gradle.
When I try to update gradle version to 1.5.0 It says:
Error:Gradle version 2.2 is required. Current version is 1.7.
If using the gradle wrapper, try editing the distributionUrl in
/Users/dubai1/ct-android/FlipNewsAppProject/FlipNewsApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.
But changing this also does not removes the Gradle Sync failed error. How can I sync and run properly?

I'm lost and desperate! Gradle is confused about what it wants; version 1.8 or 1.9?

I just upgraded Android studio and now Android Studio complaints about Gradle, saying:
You are using Gradle version 1.8, which is not supported. Please use version 1.9.
So under Preferences > Compiler > Gradle, I changed the Gradle executable to /usr/local/Cellar/gradle/1.8/libexec. After rebuilding, Android Studio then complaints again, saying
Gradle version 1.8 is required. Current version is 1.9.
If using the gradle wrapper, try editing the distributionUrl in /Applications/Android Studio.app/bin/gradle/wrapper/gradle-wrapper.properties to gradle-1.9-all.zip.
I don't know anything about a Gradle wrapper, but in my gradle.build I've got these lines for the gradle version:
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
Does anybody know how I can fix this? I'm really stuck and quite desperate! All tips are welcome!
Switch to the gradle Android plugin version 0.7+
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
Then you should be able to build with gradle version 1.9.
Make sure all your build.gradle files in the project use gradle 1.9 as dependency
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
Also check your Gradle Wrapper properties file. Its available in your project structure. It must point to gradle 1.9. AFAIK you will get pop up this fix that automatically but just confirm
Update both the build.gradle dependency as mentioned by keyboardsurfer and pyus13 and the distribution url found in gradle-wrapper.properties under /gradle/wrapper/.
Example:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip

Categories

Resources