How to fix "Could not find method" error? - android

I'm working on home work on Android studio, every thing was Ok, and I shut down my pc till next day, when i opened android studio i found this error message
ERROR: Could not find method implementation() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13-beta-3'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
// Displaying images
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
// Realtime database
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.android.support:support-v4:28.0.0'
}

Build file App Level :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//Add others below
}
Build file for Project Level :
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// 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
}
After having the same as above, you perform clean and then rebuild.

This error because of Glide library:
add following dependency too with glide dependency:
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
also if you are using androidx then you need to add :
annotationProcessor 'androidx.annotation:annotation:1.0.2'
Hope it will helps you.

This happens because the buildscript dependencies are outdated; update them to the current version, then it will know about implementation() and api() - or just use previous compile().
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
That version number always equals the version number of Android Studio; eg. build-tools 3.4.1 requires Android Studio 3.4.1 to build... updating the whole installation should automatically fix it.

Related

Error:Could not find: vectordrawable-animated-1.1.0

I have a problem with gradle. it was working fine but all of sudden when I was rebuilding the project it gives me this error:
Could not find vectordrawable-animated-1.1.0.jar (androidx.vectordrawable:vectordrawable-animated:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/vectordrawable/vectordrawable-animated/1.1.0/vectordrawable-animated-1.1.0.jar
I can't find out what my problem is?
My app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.pakagename"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.airbnb.android:lottie:3.4.1'
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.loopj.android:android-async-http:1.4.10'
implementation 'com.github.mreram:showcaseview:1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.dhaval2404:imagepicker-support:1.5'
implementation 'com.github.aliab:Persian-Date-Picker-Dialog:1.5.2'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.0'
implementation 'com.github.smarteist:autoimageslider:1.3.7-appcompat'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.jaiselrahman:FilePicker:1.3.2'
implementation 'ir.he.meowdatetimepicker:library:1.0.2'
implementation 'cat.ereza:customactivityoncrash:2.3.0'
}
and my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url 'https://maven.google.com' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://dl.bintray.com/tapsellorg/maven' }
}
}
I guess this is due to not proper download of packages (sanctions and ...).
I did following steps and worked:
Connect to VPN
Remove caches and deamons folder from ~/.gradle.
Run gradlew clean inside android folder (cleaned project gradle).
Re run the project
first remove it from you library dependency
and download aar file from below link:
https://mvnrepository.com/artifact/androidx.vectordrawable/vectordrawable-animated/1.1.0

Gradle Project Sync Failed cause Firebase installation in Android Studio

I'm trying to resolve this problem looking for the similar question as mine in Stackoverflow, I have spend 6 hours and I am not able to solve it.
I've created a new project in AndroidStudio (version 3.2) and I've installed Firebase Google. One mistake appear in Gradle, I show with a image:enter image description here
The code of app gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.android.estermateossaldana.cadenadefavores"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0'
}
The code of 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.2.0'
classpath 'com.google.gms:google-services:4.0.1'
// 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
}
Trying to solve with the indications of you, the code is like:
Gradel Build code:
// 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.2.0'
classpath 'com.google.gms:google-services:4.1.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
}
And the Gradle App code now is:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.android.estermateossaldana.cadenadefavores"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.3:15.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0'
}
I show you the error in the image:enter image description here
Version of Android Studio and Gradle: enter image description here
The option of Use default gradle wrapper is checked.
-------> New screenshot: enter image description here
Try to add this to your build.gradle dependency too:
implementation 'com.android.support:support-v4:28.0.0'
So the dependencies in app/build.gradle should be:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0' // added this
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Remember to check the samples and the libraries section.

Build.gradle: Failed to resolve: com.android.support

I'm trying to build my Android Studio project, but I keep getting this "Failed to resolve: com.android.support" error.
This is how the build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "app.training.linus.trainingapp"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.exercise_card.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'
}
And the other gradle file:
// 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.1.3'
// 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
}
I can't figure out why I can't build properly, I have the correct SDK version downloaded and everything.
Thanks in advance!
Removing
androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'
Seems to have solved it!
Will You show me the error to know problem decently?
generally, the integration problem occur if you update your studio
reinstall the studio and connect with SDK
you should check
dependency in android studio
'dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'
}'
you need to add in the project level gradle in allprojects
maven {
url "https://maven.google.com"
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}

Getting error try to connect firebase

Hellow all,
I try to connect firebase to my android app but I'm getting this error
that was triggered I'm tried to sign in to firebase using the assistant tool. I'm tried several solutions here in StackOverflow. but It does not work for me.
this the gradle build project
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is Gradle build Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.gpacalc.shannirmala.gpacalculator"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:27.1.1'
}
If you are referring firebase the first time then follow the manual setup because its increase your knowledge second time you can use the assistant tool.
Add Following dependency in Project level build.gradle file like bellow
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0' // google-services plugin
}
Then after apply plugin in your app level build.gradle at bottom of your dependency section and also add firebase dependency in dependency section like bellow.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
implementation 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support:support-v4:26.+'
compile 'com.google.firebase:firebase-core:12.0.0'
compile 'com.google.firebase:firebase-auth:12.0.0'
}
apply plugin: 'com.google.gms.google-services'
And Finally, put google-services.json file in app directory which downloaded from your firebase console after creating firebase project for your application.
How to create Firebase Project on console?

Supertypes of the following classes cannot be resolved

I have android app in kotlin which is giving me this error.
Error: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.google.firebase.auth.FirebaseAuth, unresolved supertypes: com.google.android.gms.internal.aad
and this
Error:Execution failed for task ':app:compileDebugKotlin'.
Compilation error. See log for more details
this is my app module
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "appname"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'com.android.support:mediarouter-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.0.0'
//noinspection GradleCompatible,GradleCompatible
implementation 'com.google.android.gms:play-services:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
and my project gradle is this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have firebase.auth implementation but still, it's showing me the error.
Updating com.firebaseui:firebase-ui-auth to 3.3.1 fixed it for me. As the older versions (3.1.0 in my case) was not compatible with com.google.firebase:firebase-messaging v15
Updating all the dependencies from the "com.google.android.gms:" group and also the firebase-messaging version to 15.0.0. instead of 12.0.1 fixed this issue for me.
i see at least 2 problems in your gradle file:
You have a duplicated entry for "kotlin-stdlib-jre7" (one implementation and one compile). Remove the last one:
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
Not using the latest versions of firebase & google play services: update to firebase 11.6.2
The other thing that may happen is that you are using implementation instead of api for one of your dependencies which may conflict with another dependency in your module.
Add following in gradle:-
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
If you are using firebase-bom, then you should update to latest version. For me, after upgading to latest it started working.
Lastest version as of now :
com.google.firebase:firebase-bom:24.5.0
You can check latest version HERE
add this solves my problem
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

Categories

Resources