I know this question has been asked many times and I searched through them but couldn't solve my problem. I added the
multiDexEnabled true
and also the
implementation 'com.android.support:multidex:1.0.3'
as some answers suggested but couldn't solve it. Can anyone please help me ,because since this issue occurred ,I'm stuck .
The error is `Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex`
My build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.flashcardapp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
//pin edittext library
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
// glide
implementation 'com.github.bumptech.glide:glide:3.7.0'
//amazon aws
implementation 'com.amazonaws:aws-android-sdk-core:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.13'
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.6.22'
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+#aar') { transitive = true }
implementation 'com.amazonaws:aws-java-sdk-s3:1.11.323'
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'
}
Do this in app/build.gradle:
android {
defaultConfig {
multiDexEnabled true
}
}
And after this clean and rebuild your project. Hope this works :)
I solved it by removing unused libraries and then clean and rebuild project ,as Redman suggested.
You can try this by adding MaxHeapSize into gradle file.
android {
...
dexOptions {
javaMaxHeapSize "4g"
}
}
I hope this will help you to solve the problem.
Related
i am trying to integrate firebase to my android project but constantly getting error of
"In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:17.3.4 -> com.google.firebase:firebase-iid#[17.0.4], but fire
base-iid version was 20.0.2."
my code for the app gradle build is-------
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.goldfish"
minSdkVersion 17
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'
}
}
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.google.firebase:firebase-messaging:17.3.4"
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-analytics:17.2.2'
}
Upgrade to the latest versions of the Firebase libraries:
implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
I am trying to use the Docx4j library in order to read in the contents of MS Word files selected by the user (I am trying to install it through this example: https://github.com/plutext/Docx4j4Android4). However, I receive the following error when I read in a MS Word file (I didn't include all the errors, but the duplicate classes all belong to org.slf4j.*):
Duplicate class org.slf4j.ILoggerFactory found in modules slf4j-android-1.6.1-RC1.jar (slf4j-android-1.6.1-RC1.jar) and slf4j-api-1.7.21.jar (org.slf4j:slf4j-api:1.7.21)
Duplicate class org.slf4j.IMarkerFactory found in modules slf4j-android-1.6.1-RC1.jar (slf4j-android-1.6.1-RC1.jar) and slf4j-api-1.7.21.jar (org.slf4j:slf4j-api:1.7.21)
Duplicate class org.slf4j.Logger found in modules slf4j-android-1.6.1-RC1.jar (slf4j-android-1.6.1-RC1.jar) and slf4j-api-1.7.21.jar (org.slf4j:slf4j-api:1.7.21)
........
This seems strange, since in my build.gradle, I explicity exclude org.sl4j when implementing the docx4j library.
Below is my build.gradle code:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.diffchecker"
minSdkVersion 21
targetSdkVersion 29
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dexOptions {
// Comment the following in order to see actual errors, not unhelpful "too many errors"!
// preDexLibraries = false
additionalParameters=['--core-library']
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'io.github.java-diff-utils:java-diff-utils:4.5'
// For developers using AndroidX in their applications
implementation 'pub.devrel:easypermissions:3.0.0'
// For developers using the Android Support Library
implementation 'pub.devrel:easypermissions:2.0.1'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//implementation files('libs/commons-text-1.2.jar')
implementation files('libs/commons-lang3-3.7.jar')
//Thanks for using https://jar-download.com
implementation 'org.webjars.bowergithub.telecomsante:pdf-viewer:2.2.0'
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
//implementation files('libs/commons-logging-1.2.jar')
implementation 'com.bskim:maxheightscrollview:1.0.0#aar'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
// Docx4j is the library used to read Word documents
// https://mvnrepository.com/artifact/org.docx4j/docx4j
implementation files('libs/commons-lang3-3.7.jar')
implementation files('libs/commons-text-1.2.jar')
//implementationtestCompile 'junit:junit:4.12'
implementation 'javax.xml.bind:jaxb-api:2.2.12'
implementation 'javax.xml.stream:stax-api:1.0-2'
implementation 'com.fasterxml:aalto-xml:1.0.0'
//compile 'org.codehaus.woodstox:stax2-api:4.0.0'
implementation files('libs/awt-bastardised-17v8.jar')
implementation files('libs/slf4j-android-1.6.1-RC1.jar')
implementation files('libs/activation.jar')
implementation files('libs/additionnal.jar')
implementation files('libs/jaxb-core-2.3.0-SNAPSHOT-ANDROID.jar')
implementation files('libs/jaxb-runtime-2.3.0-SNAPSHOT-ANDROID.jar')
implementation files('libs/istack-commons-runtime-3.0.4-SNAPSHOT.jar')
// with org.slf4j removed
implementation('org.docx4j:docx4j:3.3.0') {
['org.apache.commons', 'commons-logging', 'org.sl4j'].each {
exclude group: "$it"
}
}
}
And below is a screenshot of the library jar files I have:
Add the following lines in app's build.gradle
configurations {
compile.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
configurations.all {
resolutionStrategy {
force 'org.slf4j:slf4j-log4j12:1.7.25'
}
}
You can exclude org.slf4j:slf4j-api:1.7.21 and all other which are getting conflicts from org.docx4j:docx4j:3.3.0 like this
implementation('org.docx4j:docx4j:3.3.0') {
exclude group: 'org.slf4j'
}
or also you can modify your dependency like this
implementation('org.docx4j:docx4j:3.3.0') {
['org.apache.commons', 'commons-logging', 'org.sl4j', 'org.slf4j'].each {
exclude group: "$it"
}
}
When looking at org.docx4j:docx4j:6.1.2, this raises the question, what you even need libs/slf4j-android-1.6.1-RC1.jar for? org.slf4j is already included and it works on Android without these Android bindings; pdfbox-android is about the same cheese .When reading over these demands - there barely is any real attempt noticeable; because there's no Java/Kotlin code at all.
What worked for me:
implementation("org.docx4j:docx4j:3.3.0") {
exclude group: "org.slf4j"
}
configurations.all {
resolutionStrategy {
force "org.slf4j:slf4j-api:1.7.30"
}
}
I am using firebase messgessing sdk for push-notification. Here am not using androidx plugin. When am build its throw some error.
My gradle...
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.android.xxxxx"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// packagingOptions {
// pickFirst 'META-INF/*'
// exclude 'META-INF/proguard/androidx-annotations.pro'
// }
android.packagingOptions {
pickFirst 'META-INF/*'
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
configurations.all { exclude group: 'com.android.support', module: 'support-v4' }
dependencies {
ext {
support_library_version = '28.0.0'
}
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.volley:volley:1.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.android.support:multidex:1.0.3'
// implementation 'com.google.android.gms:play-services-gcm:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
Error is...
Error: Program type already present: android.support.v4.os.ResultReceiver
once i remove the firebase sdk build is working fine. I search many solutions but still not working please anyone give me a solution.
Advance thanks...
I'm creating a Uber-like app. So you can imagine the user will be able to log in using facebook/google/firebase for those using phone numbers.
The code is fine as it was used before, however I lost the previous project's gradle settings. as such now I am faced with error message
error: cannot access zzbgl class file for com.google.android.gms.internal.zzbgl not found
please help me.
I have isolated the problem. if I delete all firebase related codes, I wouldnt have this issue.
FirebaseAuth, FirebaseUser etc.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sunshinetechie.gethitched"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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.facebook.android:facebook-android-sdk:4.15.0'
implementation 'com.google.http-client:google-http-client-android:+'
implementation 'com.google.api-client:google-api-client-android:+'
implementation 'com.google.api-client:google-api-client-gson:+'
implementation "com.android.support:appcompat-v7:26.1.0"
implementation 'com.google.android.gms:play-services-maps:11.0.2'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
I have an android project that was made in eclipse, I have imported it to Android Studio started fixing the errors, but I don't know how to fix this one
I have already changed the targetSdkVersion, minSdkVersion and compileVersion, I also changed some dependencies but still not a fix
Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.wansoft"
minSdkVersion 14
targetSdkVersion 28
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation project(':sherlockSlidingMenu')
implementation project(':pullToRefresh')
implementation project(':roboAccordionView')
//compile 'com.android.support:support-v4:25.3.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
//compile 'com.android.support:support-v4:18.0.0'
implementation files('libs/commons-lang3-3.1.jar')
implementation files('libs/guice-3.0-no_aop.jar')
implementation files('libs/http-request-5.4.jar')
implementation files('libs/jackson-core-asl-1.9.11.jar')
implementation files('libs/jackson-mapper-asl-1.9.11.jar')
implementation files('libs/javax.inject-1.jar')
implementation files('libs/retrofit-1.6.1.jar')
implementation files('libs/roboguice-2.0.jar')
implementation files('libs/spring-android-core-1.0.1.RELEASE.jar')
implementation files('libs/spring-android-rest-template-1.0.1.RELEASE.jar')
implementation 'com.android.support:support-annotations:+'
}
and here is the error i get:
Android resource linking failed
/Users/dario_leija/Documents/Proyectos_Documentos/ComanderoAndroid/wansoftApp/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1550: error: resource android:attr/popupPromptView is private.
error: failed linking references.