gradle Unable to merge dex error at android studio 3 - android

I am trying run my app at emulator but I got his error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
multiDexEnabled true
applicationId "com.example.sayres.presencesystem"
minSdkVersion 16
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 {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.1'
}
and this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://maven.fabric.io/public' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
according some siggestion on some post I have added multiDexEnabled true to my gradle but I still got error. some developers at this site had suggested, rebuild project.I did this suggestion but I did work and I still got this error!!
what is your suggestion?
I still did this suggestion
but did not work again.
I do not have too many methods.I have just 2 activity and a few methods.my project is for learning.

I change my build.gradle to :
implementation 'com.google.firebase:firebase-database:10.2.0'
implementation 'com.google.firebase:firebase-auth:10.2.0'
implementation 'com.firebaseui:firebase-ui-auth:1.2.0'
implementation 'com.firebaseui:firebase-ui-database:1.2.0'
and
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
my problem fixed.now I can compile my project.

Related

android studio gradle synch error after updating to 3.2.1

I had an android project running well, but suddenly I encountered some errors which made me update my android studio to 3.2.1 and gradle to 4.6. My code is same as my colleague (all codes and versions) except one line in gradle that I will explain it later, he can build easily but I can't because of following errors:
Failed to resolve: espresso-core
Open File
Failed to resolve: multidex-instrumentation
Open File
app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.arnick.bazim"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "0.7"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id : "xxxxxxxxxxxxxx",
onesignal_google_project_number: "REMOTE"]
}
applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
implementation 'com.android.support:recyclerview-v7:27.1.1'
// the above line is showing error to me, error is about some version mismatching
// even by doing what it says the error does not disappear
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation 'com.stephentuso:welcome:1.4.1'
implementation 'co.ronash.android:pushe-base:1.4.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
implementation 'com.android.volley:volley:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
apply plugin: 'com.google.gms.google-services'
project 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: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 {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have cleaned, rebuiled, invalidated cache an restart and everything I have seen online. I even change maven reposiroty url to 2 or 3 other but error persists. What should I do? tnx

Trying to use 'com.onesignal:OneSignal:3.7.1' but getting error

i have opened a project already created. I am adding firebase and onesignal. Already added firebase but when i try to add this line getting error:
implementation 'com.onesignal:OneSignal:3.7.1'
Error is: AAPT2 error: check logs for details
images may not be displayed, sorry about that.
build.gradle (module:app) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "dedeler.com.deredere"
minSdkVersion 17
targetSdkVersion 24
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '82f1gtd7-uy16-4c37-80s4-b1ebd8ad38a6',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '837758431119'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/ftp4j-1.7.2.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.code-troopers.betterpickers:library:3.0.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.onesignal:OneSignal:3.7.1'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project) :
// 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:3.0.0'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When i delete implementation 'com.onesignal:OneSignal:3.7.1' this line project normally running, I am not getting an error. What should i do? need help..
You need to add plugin for that inside build.gradle like below.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:4.0.0'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside app level build.gradle add this.
Apply plugin at top.
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
Inside Dependencies.
implementation 'com.onesignal:OneSignal:3.9.1'
This build.gradle from doesn't work on Onesignal (and no error)
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "dedeler.com.dedede"
minSdkVersion 17
targetSdkVersion 24
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '18u4a466-37t1-4f9n-bacd-cac2ed8f9c3c',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '357658431414'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/ftp4j-1.7.2.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.code-troopers.betterpickers:library:3.0.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.onesignal:OneSignal:3.+#aar'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
}
apply plugin: 'com.google.gms.google-services'
This build.gradle from normally working on Onesignal:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.berkancalikoglu.onesignalpushdemotutorial"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '9a39e119-d312-4517-a145-ea00482fa037',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '260945562180'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-messaging:12.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'
implementation 'com.onesignal:OneSignal:3.9.2'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
}
apply plugin: 'com.google.gms.google-services'
Why does Onesignal work one and not the other?
Include this code in your App/build.gradle
implementation 'com.onesignal:OneSignal:3.9.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
i have solved by adding this classpath dependency and later change it
Just Go to Your build.gradle (android/app).
And remove the `
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
And re-run project and error will be resolved.`

After updating Gradle dependencies failed to resolve Firebase modules

I have updated my project to latest dependencies, also changed compile to implementations and gradle plugins and i have this error
Failed to resolve: firebase-analytics Open File
Failed to resolve: play-services-tasks Open File
Failed to resolve: play-services-ads-identifier Open File
Failed to resolve: play-services-stats Open File
Failed to resolve: play-services-basement Open File
Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "my.id"
minSdkVersion 16
targetSdkVersion 28
versionCode 36
versionName "2.04"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
//multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/chartboost.jar')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:percent: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.jakewharton:butterknife:8.8.1'
implementation 'com.github.polok:clicknumberpicker:0.1.2'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.kila.apprater_dialog.lars:apprater-dialog:1.0.5'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-crash:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.android.billingclient:billing:1.0'
testImplementation 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'
Project
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:3.5.0"
// 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
}
Tried a lot of combinations, can someone help?

Android 3.0.1 does not resolve dependency

I want to add those dependencies:
implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation 'com.multidots:fingerprint-auth:1.0.1'
in android studio 3.0.1 with gradle 3.0.1 but I get the following error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.multidots:fingerprint-auth:1.0.1.
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.andrognito.pinlockview:pinlockview:2.1.0.
My build.gradle files are:
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
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
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And the other one:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.b.jacob.gallery"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support:design:24.2.1'
implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation 'com.multidots:fingerprint-auth:1.0.1'
testImplementation 'junit:junit:4.12'
}
It's important to say that those dependencies resolve without any problem in older version of android studio.
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support:design:24.2.1'
and
buildToolsVersion '26.0.2'
cannot go together there will be a conflict
Your changes should be :-
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:design:26.0.2'
and
compileSdkVersion 26
Note
Dont forget to make sure Offline Work is unchecked in android studio...and you are connected to internet
These are the probable reasons why the dependencies cant be resolved !!

Firebase Android Studio (2.2.3) issue

I am facing a problem to compile Firebase in my android project.Here is my app level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "<my_app_id>"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'me.relex:circleindicator:1.2.2#aar'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.firebase:firebase-core:10.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And here is the build gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.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
}
I am getting an error of Failed to resolve : com.google.firebase:firebase-core:10.2.1
If you are using android studio,
Goto tools -> Firebase
And follow on screen instructions. Android studio take care of the dependency issues.
Change
compile 'com.google.android.gms:play-services-auth:10.2.1'
to
compile 'com.google.android.gms:play-services-auth:10.0.1'
It works for me.
update your play service version and also update firebase dependency version.

Categories

Resources