What does "duplicate class" mean? - android

I have problem with running my app. All of a sudden, the app began producing this error "duplicate class com.google.android.gms.location.places".
And I'm not even joking, I've been searching this whole site to fix this error, even deleting all project and creating a new one. But nothing, no. NOTHING solves it!
I believe I've been reading each single thread on this topic. Ofc, there's a solution there! It just happens to not be the correct solution for me...
This is the error line:
Duplicate class com.google.android.gms.location.places.zza found in modules classes.jar (com.google.android.gms:play-services-places-placereport:16.0.0) and classes.jar (com.google.android.gms:play-services-places:9.6.1)
This is my dependencies and app.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.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {url 'https://jitpack.io'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.qwisenow"
minSdkVersion 22
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.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0' // FusedLocationProviderClient
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.stripe:stripe-android:8.7.0'
implementation 'com.github.f0ris.sweetalert:library:1.5.6'
implementation 'com.ebanx:swipe-button:0.8.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation 'com.braintreepayments:card-form:3.1.1'
implementation 'com.github.aarsy.googlemapsanimations:googlemapsanimations:1.0.5'
implementation 'com.android.support:cardview-v7:28'
implementation 'com.vipulasri:ticketview:1.0.7'
implementation 'me.philio:pinentryview:1.0.6'
implementation 'com.github.ar-android:DrawRouteMaps:1.0.0'
implementation 'com.codemybrainsout.onboarding:onboarder:1.0.4'
implementation 'com.karumi:dexter:5.0.0'
}
Can anybody see something looks "duplicate" there? I can't, and I've tried probably 30 solutions on this, but Android Studio keeps give me errors...

Related

I tried connecting my Android project with Firebase but JSON file error is coming

this is my build.gradle(.app) file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.moviebookingapp"
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-database:19.5.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation'com.android.support:recyclerview-v7:29.3.1'
implementation 'com.basgeekball:awesome-validation:1.3'
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation'com.google.firebase:firebase-database:19.5.1'
}
this is my build.gradle(movie booking app) 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:4.1.0'
classpath "com.google.gms:google-services:4.3.4"
// 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
}
google-services(1).json is the file which I have added
this is error is coming.
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
D:\ankita\android\moviebookingapp2\app\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnull\google-services.json
D:\ankita\android\moviebookingapp2\app\src\debug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnullDebug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnull\debug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\debug\nullnull\google-services.json
I tried many other approaches, I also searched that the file is added or not, all I have searched, I don't know where I went wrong.
I ran into this issue at the start when I created my project. Make sure you have the proper json file added. Your current json file says "google-services(1).json". The app doesn't recognize the (1) and so it thinks it is a different file. Rename that to "google-services.json" and your code should work. It' kinda annoying that they are treated differently and I spent a lot of time at the start working this out too.
Before: google-services(1).json
After: google-services.json

Error: Program type already present: com.google.android.gms.common.internal.zzb

I have a problem doing "Generate Signed Bundle" with information "Generate Signed Bundle: Errors while building Bundle file. You can find the errors in the 'Messages' view."
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "net.persmaeuridice.rppkurikulum2013revisi"
minSdkVersion 16
targetSdkVersion 28
versionCode 3
versionName "3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation 'com.firebaseui:firebase-ui:0.6.2'
implementation 'com.github.hani-momanii:SuperNova-Emoji:1.0'
implementation 'com.github.lguipeng:BubbleView:1.0.1'
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'
}
I have done many ways to find a solution to the limits of my ability, for that I need your help to solve my problem
where did I make a mistake?
// 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.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()
maven {
url "https://maven.google.com"
}
maven {url "https://jitpack.io",}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
there is a conflict between this two library
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.firebaseui:firebase-ui:0.6.2'
try to remove if any one is not needed

ERROR: Unable to resolve dependency for ':Aware#debug/compileClasspath': Could not resolve project :aars

I'm trying to use pocketsphinx in my android app and its giving me trouble. I've installed it as outlined here: PocketSphinx on Android, specifically by importing the .aar. Here is my code:
project build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
classpath 'com.android.tools.build:gradle:3.2.1'
//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
Application build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "kutz.connor.Aware"
minSdkVersion 26
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'
}
DexOptions {
matchingFallbacks = ['debug', 'release']
}
}
}
dependencies {
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.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'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'org.tensorflow:tensorflow-lite:+'
implementation project(':aars')
}
apply plugin: 'com.google.gms.google-services'
And the error I get is
ERROR: Unable to resolve dependency for ':Aware#debug/compileClasspath': Could not resolve project :aars.
ERROR: Unable to resolve dependency for ':Aware#debugAndroidTest/compileClasspath': Could not resolve project :aars.
ERROR: Unable to resolve dependency for ':Aware#debugUnitTest/compileClasspath': Could not resolve project :aars.
when I try to build the project. Upon research I've seen that this probably has to do with updating Androdi Studio to 3.0.
Some solutions I have tried:
Adding matchingFallbacks for debug, release in the build.gradle function
Creating a settings.gradle for the project
Any help would be great. I've seen on posts to move all buildtypes to the app gradle as well but I'm unsure of exactly how to do that.
EDIT
Here is the settings.gradle file in the project folder, it has only one line
include ':Aware', ':aars'

Unable to resolve dependency firebase and google play service

I am trying to connect my android project to firebase. It was working also properly in starting. I don't know what happened all by sudden i am got series of Unresolved dependencies.
I have done almost all steps which I found over web. Like disable offline work, Invalidate chache/restart. Even when I am creating new project I am facing same problem. Earlier this all things were not happening.
My application gradle code is :
// 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.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle for module
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.aabsys.metasensing"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "2.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'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7: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-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}
apply plugin: 'com.google.gms.google-services'
Thanks in advance.Please find image
Try adding the following dependency in your code:-
implementation 'com.google.android.gms:play-services:12.0.1'
If it still does not resolve your issue, try updating Google play services and Google repository.
Try to change the class path
classpath 'com.google.gms:google-services:4.2.0'
I solved my issue by reducing google service version to :
classpath 'com.google.gms:google-services:4.0.0'
And removing
implementation 'com.google.firebase:firebase-core:16.0.1'

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.

Categories

Resources