I have implemented phone number detection and SMS verification functionality into my project by referring to this project
https://www.programcreek.com/java-api-examples/?code=android%2Fidentity-samples%2Fidentity-samples-master%2FSmsVerification%2Fapp%2Fsrc%2Fmain%2Fjava%2Fcom%2Fgoogle%2Fsamples%2Fsmartlock%2Fsms_verify%2Fui%2FPhoneNumberActivity.java#
I downloaded and imported volley from the link below
https://github.com/google/volley
I am getting an error while building my project, please guide me I am new to android studio...
Error
Unable to find method 'org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()Lorg/gradle/api/file/FileCollection;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Update:
I deleted gradle file from C:\Users\MY PC.gradle\wrapper\dists and rebuilt the project and now I am getting this error
Error Unknown host 'services.gradle.org'. You may need to adjust the
proxy settings in Gradle. Enable Gradle 'offline mode' and sync
project Learn about configuring HTTP proxies in Gradle
change the distributionUrl in the gradle-wrapper.properties to distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip to get the build running again. This seems to be a similar problem Gradle sync failed: Unable to find method.
Related
After updating Android Studio to Bumblebee 2021.1.1 Patch 2 I encountered failures that I hadn't before. For example, after a Build/Make Project attempt under Build/Sync there are 23 messages of the form:
Failed to resolve: com.squareup.leakcanary:leakcanary-android:2.8.1
Show in Project Structure dialog Affected Modules: app
I searched for com.squareup.leakcanary and found that it is not at the repository set in build.gradle, so I added that repository to my build.gradle file as the second URL under allprojects/repositories as I believe that Declaring repositories intends:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
//jcenter()
mavenCentral()
}
dependencies {
def nav_version = "2.4.1"
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
//jcenter()
google()
maven { url 'https://maven.google.com' }
maven { url 'https://mvnrepository.com/artifact/com.squareup.leakcanary'}
//maven { url 'https://mvnrepository.com/'}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The following warning is found under Build Output:
Could not HEAD
'https://mvnrepository.com/artifact/com.squareup.leakcanary/com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'.
Received status code 403 from server: Forbidden Disable Gradle
'offline mode' and sync project
Clicking on the URL in that message results in the following from mvnrepository.com:
Not Found For request 'GET
/com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'
Obviously the process made a call that was rebuffed. The following line for leakcanary is in my app build.gradle (app) file:
// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
According to Getting started that is all that is required to use leakcanary, which is why I use it as an example, it fails now when it worked before as shown on that web page.
Something happened with this update that led to gradle not being able to resolve dependencies that it did previously. I have 23 of these to deal with and would like to understand what is going on and what I can't see in the Bumblebee update information or the Gradle documentation. I've read Verifying dependencies, but a resolution does not jump out at me.
All of the stackoverflow search results mentioned doing one of the following that I have ensured were done:
Offline mode is disabled
Performed File/Invalidate caches
Commented out jcenter() as its no longer receiving updates
Updated current revisions in build.gradle (app)
Performed Build/Clean Project
Followed all suggestions in Bumblebee update and subsequent ones identified in build.gradle (app) for the individual dependency revisions
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
gradle-wrapper
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Could not find com.android.tools.build:gradle:4.0.0.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom
I struggled in a similar question after upgrading the Android Gradle Plugin Version from 3.3.0 to 4.0.0 of a React Native project as suggested by Android Studio. I followed the answer but it still do not sync correctly.
Finally I run rm -rf node_modules and re-install all the dependencies by npm install. After that I sync again and it sync correctly. I guess that there are some caches in different node modules that are not cleaned properly. I hope if someone encounter similar problem can try and see if my answer fix the problem.
I faced this issue after Invalidating caches under File -> Invalidate Cache/Restart
Later deleted node_modules under project folder and then did an npm install.
On Click of File -> Sync Project with Gradle Files resolved this issue
After Android Studio Upgrade it shows following error when sync project with gradle files:
ERROR: Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Project Build Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle-wrapper properties
#Fri Apr 17 20:10:05 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
----Use graddle from is set to gradle-wrapper-properties file
----Android Gradle Plug in version is 3.6.2
Gradle version is 5.6.4
Changed gradle version also still showing error
Event log
9:03 PM Gradle sync failed: Cause: error in opening zip file
Consult IDE log for more details (Help | Show Log) (16 m 50 s 157 ms)
9:03 PM Android Studio is using the following JDK location when running Gradle:
I:\Android\android-studio-ide-192.6308749-windows32_17-4-2020\android-studio\jre
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.
More info...
Select a JDK from the File System
Do not show this warning again
i want to import a project in to android studio but i have an error gradle sync failed .
this is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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
}
Gradle sync failed: Cause: com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
Consult IDE log for more details (Help | Show Log)
i changed the distributionUrl but doesn't solve the problem .
my gradle-wrapper propertice:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
i searched the net for 3-4 hours but there was no solution for my problem that can solve my problem .
Hope it works
File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.
I've recently updated android studio to 2.3...After update it is continuously refreshing the project.So I clicked on invalidate cache and restart..After that it is showing this error
This is the error image
This is my build.gradle file
// 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.3.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
}
This is my gradle-wrapper.properties file
#Mon Mar 13 16:42:48 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
This is my gradle location
C:/Program Files/Android/Android Studio/gradle/gradle-3.2
Everything seems to be good to me.I dont know what should I change...Please help me
Click on the blue link - Upgrade Gradle Wrapper - that should fix it
For those who face similar problem here is the solution.Download gradle files manually from internet which is of around 80 mb and replace these new files with those of old ones in android stuido.