Unable to merge dex when adding firebase dependency - android

I am trying to add firebase push notifications to app. I started with a fresh application with Basic Activity but facing errors
First I got below error during gradle build
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in
project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1)
differ. See https://d.android.com/r/tools/test-apk-dependency-
conflicts.html for details.
then I added dependency in app level build.gradle and issue resolved
implementation 'com.android.support:support-annotations:27.1.1'
then I got some font related errors which was resolved by changing compileSdkVersion 28
from 26 in app gradle build
Then I followed the steps to add firebase to my project. The gradle sync worked properly but when I am trying to Run the app in my connected device its showing
Error:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I tried a few solutions from but none of them worked for me.
app level build.gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rakesh.firecast"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
multi
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.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.android.support:support-annotations:27.1.1'
implementation 'com.google.firebase:firebase-core:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
Project level build.gradle
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"
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
}
Please help me figure it out and resolve this issue

Related

Could not find dependency "com.google.android.gms:play-services-maps:17.0.0" [duplicate]

Please help me...
I want to create a project based on Google Maps. But after building gradle in Android Studio, The following error occurs:
ERROR:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
When i clicked on the 'Install Repository and ...' then this message appear:
Could not find dependency "com.google.android.gms:play-services-maps:17.0.0"
NOTE:
Gradle work online mode.
I went to Setting and Android SDK then downloaded google play services.. but it is not working for me.
I also set up a proxy.
EDIT:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
root gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After much effort, I was able to solve the problem.
Strange as it may seem, the problem was solved by manually adjusting the proxy.
thanks all.

google-play-services-maps:17.0.0 is not working even with default project Android Studio created

Please help me...
I want to create a project based on Google Maps. But after building gradle in Android Studio, The following error occurs:
ERROR:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
When i clicked on the 'Install Repository and ...' then this message appear:
Could not find dependency "com.google.android.gms:play-services-maps:17.0.0"
NOTE:
Gradle work online mode.
I went to Setting and Android SDK then downloaded google play services.. but it is not working for me.
I also set up a proxy.
EDIT:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
root gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After much effort, I was able to solve the problem.
Strange as it may seem, the problem was solved by manually adjusting the proxy.
thanks all.

I have a gradle sync error JAVA_LETTER_OR_DIGIT when trying to add Firebase to my android project

When I added the dependencies as told in the firebase guide and sync the project ,I get the error JAVA__LETTER_OR_DIGIT .I work with MAC OS X Yosemite and my android studio version is 3.1.4
My app grade file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "e.apple.mse_project"
minSdkVersion 22
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 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-analytics:17.2.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'
}
apply plugin: 'com.google.gms.google-services'
My project grade 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.4'
classpath 'com.google.gms:google-services:4.3.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
}
This is the error that I get in the build console
The error log that shows in my build console
Thanks in advance !
The problem is with Android gradle plugin which doesn't work well with Google's Maven repository.
You can downgrade your google-services down to 4.2.0 as it was said by #mownathi-manigundan. Version 4.2.0 is available in AndroidTools Repository which outdated gradle plugin handles just fine
But it'd be better to update your plugin up to 3.2 or higher and use recommended com.google.gms:google-services:4.3.2. You can read more here how to to this
Try changing your version of gms google service in your project gradle as com.google.gms:google-services:4.2.0

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'

Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app and test app differ

Today I started a new project in android studio. Everything went good and there was no error. After Adding the project, I connected the project with Firebase Real-time Database with the help of Firebase assistant tool in android studio.
Then I get this error:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (23.0.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
I see that the error mainly comes from adding this line at the end of my app level build.gradle file. Because when I comment it out, it builds fine.
apply plugin: 'com.google.gms.google-services'
I don't know much about gradle building system. What could be wrong with only connecting to firebase and adding the firebase-database dependencies.
Resources that me need inspection
My app:build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.learning.insanes.chothavandar"
minSdkVersion 21
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.constraint:constraint-layout:1.0.2'
// implementation 'com.google.firebase:firebase-database:11.6.0'
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'
}
apply plugin: 'com.google.gms.google-services'
My 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.0.1'
// 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.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Try this:
androidTestCompile ("com.android.support.test.espresso:espresso-core:3.0.1") {
exclude group: 'com.android.support', module: 'support-annotations'
}
Look at this link for better understanding
In your app: build.gradle file in dependencies add the following lines or if already there change it as:
dependencies {
..
implementation 'com.android.support:appcompat-v7:25.4.0'
..
}

Categories

Resources