Unable to Merge Dex Android Studio 3.0 after update - java

updated my project to gradle 3 and generated this error
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
in another questions says "libraries having transitive dependency " but i don't find the library with this transitive dependency
in gradle 2.3 don't show this error
build.gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileOptions.encoding = 'UTF-8'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.my.my"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ["libs"]
}
}
packagingOptions {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':dd-plist')
compile project(':Emojicon')
compile project(':CameraModule')
compile project(':ScapeUtils')
compile project(':circleimageview')
compile project(':FFMPG')
compile project(':PdfViewer')
compile project(':LibLinphone')
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.ornolfr:rating-view:0.1.1#aar'
compile 'cat.ereza:customactivityoncrash:1.5.0'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile "com.android.support:appcompat-v7:26.1.0"
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'org.apache.commons:commons-io:1.3.2'
}
apply plugin: 'com.google.gms.google-services'
build.gradle project
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}

I am battling also with this or similar problem. I have set to use the old gradle version manually. From File/Project structure/projet I have put gradle version 3.4.1 and plugin version 2.3.3
I have also added multiDexEnabled true in app/build.gradle inside defaultConfig Hth

Related

Android studio Unable to merge dex only on rebuild

I have an android project created with android studio 2.3.
Now I have upgraded to android studio 3 and I have the following error.
When I ran my app it compiles normally and is installed in my device. It works fine. Any changes I make to the code are visible in the device.
But when I try to rebuild i get the following error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
this happens only on rebuild. I have tried to clean and rebuild and also i have done invalidate cache/Restart.
What is the problem?
EDIT:
My app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "gr.myapp1"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
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 project(':CoreServices-3.14.5')
compile project(':maflogoncore-1.214.5')
//compile project(':maflogonui-1.214.5')
compile project(':mafsettingscreen-1.214.5')
compile project(':mafuicomponents-1.214.5')
compile project(':MobilePlace-3.14.5')
compile project(':ODataOnline-3.14.5')
compile project(':Request-3.14.5')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.support:cardview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
//firebase
apply plugin: 'com.google.gms.google-services'
my project 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:3.0.0'
//firebase
classpath 'com.google.gms:google-services:3.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
}
Eventually i had to enable multidex although i had minimumVersion: 21
Maybe because when i created the project i had it set to 19 and i changed it to 21.
I haven't found why it worked all this time without multidex and now that i upgraded to Android studio 3 it requires it.

Couldnt find solution for - Error:Execution failed for task

I have tried everything what i found while googling but still have a mistake.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbut.class
My gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.6'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
This is because of your "multidex" dependency and "multiDexEnabled true" in debug flavor.

why android studio showing error "Error:(38, 0) Plugin with id 'com.google.gms.google-services' not found"

This is my gradle.build on app given below it shows error:
Error:(38, 0) Plugin with id 'com.google.gms.google-services' not found.
Is there any answer?
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.admin.youfame"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.google.apis:google-api-services-youtube:v3- rev152-1.21.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Add in your top-level build.gradle the google play services plugin:
buildscript {
repositories {
jcenter()
}
dependencies {
//...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Then you have to add in your module the google-services.json file
root
|--module
|----google-services.json
You need to delete the code apply plugin:
com.google.gms.google-services
and it works.

Error: package com.lapism.searchview.view does not exist

I have used searchview in my project with dependency compile 'com.lapism:searchview:3.0.2' in build.gradle file. But while I'm trying run the application I'm getting an error
Error: package com.lapism.searchview.view does not exist
Error:
cannot find symbol class SearchView
Error:Execution failed for task
':app:compileDebugJavaWithJavac'.
My current android version is 2.1
My Build.gradle File:
buildscript {
repositories
{
maven { url 'https://maven.fabric.io/public' }
}
dependencies
{
classpath 'io.fabric.tools:gradle:1.+'}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
multiDexEnabled true
applicationId "pingo.betnek.mobigrab"
minSdkVersion 16
targetSdkVersion 15
versionCode 2
versionName "1.1"
}
dexOptions
{
incremental true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies
{
provided fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'io.realm:realm-android:0.87.2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.lapism:searchview:3.0.2'
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.7'
compile 'com.android.support:multidex:1.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar')
{
transitive = true;
}
}
Show us your code usage..
In any case, change com.lapism.searchview.view.SearchView to com.lapism.searchview.SearchView, or just remove the imports and let Android Studio re-import them with the correct namings.
It has been refactored since 2.3 or whatever version..

android error : Gradle sync failed: Gradle DSL method not found: 'classpath()'

hi i'm newbie with Android studio, after updating from android studio 1.4 to 2.1, I am getting the following build error when I try and sync my project:
Gradle sync failed: Gradle DSL method not found: 'classpath()'
and Here is the build.gradle:
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "android.arisa.---------"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
compile('com.afollestad.material-dialogs:core:0.8.1.0#aar') {
transitive = true
}
compile('com.afollestad.material-dialogs:commons:0.8.1.0#aar') {
transitive = true
}
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
//compile 'com.android.support:multidex'
//compile 'com.mcxiaoke.volley:library-aar:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.+'
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/.idea/libraries/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/libraries/jsoup-1.8.3.jar')
compile 'com.google.android.gms:play-services:8.3.0'
}
repositories {
jcenter()
}
//repositories {
// maven { url "https://jitpack.io" }
//}
and the gradle-wrapper.properties is:
#Sat Apr 30 11:59:41 2016
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
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
How can i correct this?(please help me)
edit: After editing grade, my android gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "android.arisa.kalahroodfinal"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
compile('com.afollestad.material-dialogs:core:0.8.1.0#aar') {
transitive = true
}
compile('com.afollestad.material-dialogs:commons:0.8.1.0#aar') {
transitive = true
}
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/.idea/libraries/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/libraries/jsoup-1.8.3.jar')
compile 'com.google.android.gms:play-services:8.3.0'
}
but i have new error:
Error:(43, 13) Failed to resolve: com.afollestad.material-dialogs:commons:0.8.1.0
Error:(40, 13) Failed to resolve: com.afollestad.material-dialogs:core:0.8.1.0
Try to remove the classpath 'com.android.tools.build:gradle:2.1.0' string.
I also would recommend you to create new project in Android studio 2.1 and compare the gradle files generated by IDE with yours.
You are using
classpath 'com.android.tools.build:gradle:2.1.0'
in the wrong block.
More it in the top-level build.gradle file (in the root of your project)
// 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.1.0'
}
}
To solve the issue with the library material dialog you have to add the repository from which download the dependencies:
In your top-level build.gradle file add the jitpack repo:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}

Categories