Pdf Viewer gradle problem in android studio - android

when i add this : implementation 'com.github.barteksc:android-pdf-viewer:2.8.2' in gradle build
then run this and then showing error that is given below: Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-compat-25.3.1-runtime (com.android.support:support-compat:25.3.1)

Related

Android Studio Chipmunk duplicate class error

I am getting the following error when Gradle is set 7.2.2.
Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
This is not in my program but in Android Studio.
How do I correct the problem?
Thanks,
Bill
In your build.gradle try adding this:
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
This worked for me.
I added it but no change.
Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
This error is caused by duplication of dependencies
To solve the same:
You must open Gradle Scripts-->build.gradle(Module: YourApp)
Or
You can just choose to search the builder:app file in Navigate--> Search Everywhere, type "build.gradle " and choose the option that appears build.gradle (: app)
Inside your build.gradle file it checks which of the implementations made in the dependencies tag was duplicated and deletes one of them.
Now
rebuild your app and good work!

Duplicate class com.google.zxing.Binarizer found in modules jetified-com.google.zxing.client.android.captureactivity.jar and jetified-core-3.3.3.jar

So I tried running ionic cordova run android but I get a build failed with an exception.
Duplicate class com.google.zxing.Binarizer found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.BinaryBitmap found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ChecksumException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.DecodeHintType found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.EncodeHintType found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.FormatException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.LuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatReader found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter$1 found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.NotFoundException found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.PlanarYUVLuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.RGBLuminanceSource found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Reader found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
And the list goes on and finishes with :
Duplicate class com.google.zxing.qrcode.encoder.QRCode found in modules jetified-com.google.zxing.client.android.captureactivity.jar (com.google.zxing.client.android.captureactivity.jar) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Go to the documentation to learn how to Fix dependency
resolution errors.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 7.0. Use '--warning-mode all' to show the
individual deprecation warnings. See
https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
Here is my build.gradle file :
buildscript {
ext.kotlin_version = '1.3.50'
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
apply from: 'repositories.gradle'
repositories repos
project.ext {
defaultBuildToolsVersion="29.0.2" //String
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I Tried :
Adding : configurations {compile.exclude group: 'com.google.zxing'} to build.gradle
removed the android platform from cordova and then adding it.
removed the barcodescanner plugin then adding it.
I have been stuck with this one for almost a week.
The problem was caused because of a conflict between facebook4 plugin and barcodeScanner plugin. Both use a library called ZXing which will cause a conflict.
The easy fix (hard to find) was to remove the facebook plugin and add the same one without the zxing library.
ionic cordova platform rm android
ionic cordova plugin rm cordova-plugin-facebook4 --save --variable APP_ID="ID" --variable APP_NAME="NAME"
ionic cordova plugin add https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing --save --variable APP_ID="ID" --variable APP_NAME="NAME"
ionic cordova platform add android
ionic cordova platform rm android
This fixed my problem. Note that there is nothing to edit in your code.
Check the git repo for more info: https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing
For me, the solution was to remove implementation files('libs/core.jar') from my build.gradle:
dependencies {
..........
implementation files('libs/core.jar') // Remove this line
implementation 'com.facebook.android:facebook-login:latest.release' // Conflicting with libs/core.jar.
..........
}

Duplicate class in modules dagger-1.2.2.jar and dagger-2.22.jar

After upgrading all libraries to androidx and to the latest versions of Firebase libraries
I got error with 2 different versions of dagger java files, link in the error message doesn't work. Problem occurs at step :app:checkDebugDuplicateClasses.
I do not use dagger directly in my code, using
./gradlew app:dependencies
I found what com.google.android.gms:play-services-cast-framework:17.1.0 uses com.google.dagger:dagger:2.22, but no info about 1.2.2.
Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class dagger.Lazy found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.MembersInjector found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.Module found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.Provides found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class javax.inject.Inject found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Named found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Provider found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Qualifier found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Scope found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Singleton found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Go to the documentation to learn how to Fix dependency resolution errors.
The easiest way is to analyze dependencies.
SOLUTION #1 (console only)
Run in console:
./gradlew -q dependencies app:dependencies
After receiving list of dependencies in the console, go to Analyze part (below Solution #2).
SOLUTION #2 (generate html)
1) Add plugin to generate report
In to app/build.gradle (this with compileSdkVersion, targetSdkVersion or buildTypes), at the top add:
apply plugin: 'project-report'
near one of them:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
which are on top.
2) Generate report
Just from the console run:
./gradlew htmlDependencyReport
or from Android Studio
Tasks > other > htmlDependencyReport
3) Open report
In console you will find URL:
./gradlew htmlDependencyReport
> Task :app:htmlDependencyReport
See the report at: file:///Users/user_name/your_path/project_name/app/build/reports/project/dependencies/index.html
And go to the project ':app'
4) Analyze report
After clicking each of the position there are dependencies:
To expand all of them, you can in develper console such code:
$('#dependencies').html(function(index, html) {
return html.split('style="display: none;"')
.join('style="display: block;"')
.split('<h3 class="closed">')
.join('<h3>')
});
ANALYZE
1) Find old dependencies
In your case you are searching phrase dagger:1
Or in the console:
2) Exlude dependencies
Find in the report library name, and just exclude group from this import.
In your build.gradle (where you have all of dependencies) modify "problematic" library excluding dagger v1.
For example:
implementation("some.old.library.using.dagger1:1.0.0") {
exclude group: 'com.squareup.dagger', module: 'dagger'
}

Manifest merger error with com.google.android.material:material

I am getting following error :
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
.......
andin my gradle file there is following dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
}
I do not know what is the problem I tried multiple solution including this but did not get rid of this. Please help
It seems like a conflict between androidX and support libs.
If you are not supporting yet androidX you need to replace
implementation 'com.google.android.material:material:1.0.0' by implementation 'com.android.support:design:28.0.0'.
If you still want to use the material version, make sure your gradle.properties file has androidX and Jetifier enabled.
android.useAndroidX=true
android.enableJetifier=true
Make sure you follow the necessary setup to use material. Check it out here.

Android build error when implementing google places sdk

Hello everyone I am developing simple food delivery android application so its required to integrate google maps and auto suggestion I follow to find current location
[google sample code](https://github.com/googlemaps/android-samples/blob/master/tutorials/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.java)
and for Auto suggestions I followed
https://developers.google.com/places/android-sdk/autocomplete
when build it gradle shows duplicate class error
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$StructuredFormatting found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$Substring found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.FetchPlacePabloResponse found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bc found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bd found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.be found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
And this my gradle
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
i try to exclude duplicate classes by below way
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation ('com.google.android.libraries.places:places:1.1.0'){
exclude group:'com.google.android.libraries.places.api.internal.impl.net.pablo'
exclude group: 'com.google.android.libraries.places.internal'
}
But no thing can solve my problem.
Remove
implementation'com.google.android.libraries.places:places-compat:1.1.0'
and keep only implementation 'com.google.android.libraries.places:places:1.1.0'.
Using implementation 'com.google.android.libraries.places:places-compat:1.1.0'
is neccessary only if you are using deprecated library of
implementation 'com.google.android.gms:play-services-places:16.0.0'
Please take a look here and documentation.

Categories

Resources