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.
Related
Android Studio Upgrade Assistant recommends to update Android Gradle Plugin from version 7.0.0. to x.x.x. However, the problem is that it alerts "Cannot find AGP version in build files". I'm struggling with this message and I found the empty AGP version in my project structure. I've already checked
gradle-7.3-bin
inside
C:\Users\abc.gradle\wrapper\dists' and allocated 'Gradle user home'
as 'C:\Users\abc\.gradle.
That dropdown button below the 'Android Gradle Plugin Version' has nothing and I want to find out why and how to fix it. Is this related with the AGP upgrade?
I got the same error when in Android Studio I tried to use Tools > AGP Upgrade Assistant.
For those who don't know, the Android Gradle Plugin is the dependency com.android.tools.build:gradle: specified in the project-level build.gradle (to be clear, not my module-level build.gradle).
In my case, the problem was that my project-level build.gradle file specified the version of the Android Gradle Plugin using a variable rather than hardcoding the version.
My project had the following variable in my gradle.properties and referenced it in my build.gradle file:
gradle_version=7.2.2
It referenced it in the project-level build.gradle file like this:
classpath "com.android.tools.build:gradle:$gradle_version"
To fix the problem, I changed my project-level build.gradle file from this:
classpath "com.android.tools.build:gradle:$gradle_version"
To this:
classpath 'com.android.tools.build:gradle:7.3.1'
After that change, Tools > AGP Upgrade Assistant stopped complaining "Cannot find AGP version in build files". Furthermore, I was able to use AGP Upgrade Assistant to upgrade from com.android.tools.build:gradle:7.2.2 to com.android.tools.build:gradle:7.3.1.
Gradle DSL method not found: 'google()' Possible causes: The project 'My Application' 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 4.0.1 and sync project The project 'My Application' may be usplease
First of all you have to Upgrade plugin to version 4.0.1 and sync project. It will upgrade by clicking text of Upgrade plugin as it automatically navigates towards updating required plugin .
Also
To use the DSL implementation() you have to use:
The updated gradle plugin for Android 3.0.0.
The gradle version 3.4 or later.
Then in your build.gradle you have to use:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
}
}
In your gradle-wrapper.properties
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
More detailed info here.
I am trying to integrate google play billing library with my android application and when I try to add this dependency (compile 'com.android.billingclient:billing:1.0') in the app module's build.gradle file. I get the following error:
ERROR: Gradle DSL method not found: 'compile()'
Possible causes:
The project 'work' 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.4.1 and sync project
The project 'work' 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
Can anyone help?
Thanks already.
Go to Build.gradle(Module:App) :
dependencies {
implementation 'com.android.billingclient:billing:1.0'
}
Below dependency should not be added in top level gradle
compile 'com.android.billingclient:billing:1.0'
Add it in app module gradle.
And compile keyword is deprecated now you can use below new version
implementation 'com.android.billingclient:billing:1.0'
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.
In Event Log,
Gradle sync failed: Could not find method screengrabVersion() for arguments [/Users/adminuser/Desktop/MyProject/version.properties] on project ':screengrab-lib' of type org.gradle.api.Project.
In Message Gradle Sync,
Error:(5, 0) Gradle DSL method not found: 'screengrabVersion()'
Possible causes:
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 2.3.3 and sync projectThe project 'MyProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
And nothing happen when I Click on "Upgrade plugin to version 2.3.3 and sync project"
I am using Android Studio version 2.3.3. Please help me on it.
After checking many hours I removed module dependency and put below Gradle dependency in App build.gradle file and It's working fine now,
androidTestCompile("tools.fastlane:screengrab:1.0.3", {
exclude group: 'com.android.support', module: 'support-annotations'
})