react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Android release build error - classes defined multiple times

Open himat opened this issue 5 years ago • 6 comments
trafficstars

Your Environment

  • Plugin version: 0.6.3
  • Platform: Android
  • OS version: MacOS 10.14.5
  • React Native version: 0.61.5

When I run ./gradlew bundleRelease, I get this error

Type org.apache.commons.io.Charsets is defined multiple times:  /Users/x/Workspace/Web/x/node_modules/@mauron85/react-native-background- 
 geolocation/android/common/build/.transforms/a8e102993c8c7adae72bf050e6cc7e7e/classes/classes.dex,   
/Users/x/Workspace/Web/x/android/app/build/intermediates/external_libs_dex/release/out/classes2.dex

Here is my android/build.grade file in my react native project

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28

        googlePlayServicesVersion = "17.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.6.4')
        classpath 'com.google.gms:google-services:4.3.3'

    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {

            url("$rootDir/../node_modules/react-native/android")
        }
        maven {

            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url 'https://maven.google.com'  }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

I'm able to build the app and the gps is working with yarn react-native android for local debug building. But the release build is failing using the command above.

How do I resolve this?

himat avatar Aug 01 '20 03:08 himat

I ran ./gradlew app:dependencies and this gave me

+--- project :mauron85_react-native-background-geolocation
|    +--- project :@mauron85_react-native-background-geolocation-common
|    |    +--- com.google.android.gms:play-services-location:17.0.0 (*)
|    |    +--- com.android.support:support-compat:28.0.0 -> androidx.core:core:1.1.0 (*)
|    |    +--- com.android.support:appcompat-v7:28.0.0 -> androidx.appcompat:appcompat:1.1.0 (*)
|    |    +--- com.intentfilter:android-permissions:0.1.7
|    |    +--- com.github.tony19:logback-android:1.1.1-9
|    |    |    \--- com.github.tony19:apktool-lib:1.4.4-5
|    |    +--- org.slf4j:slf4j-api:1.7.21
|    |    \--- com.github.jparkie:promise:1.0.3
|    +--- org.slf4j:slf4j-api:1.7.21
|    \--- com.facebook.react:react-native:+ -> 0.61.5 (*)

which seems fine and it doesn't seem like there are any same modules imported at the highest level.

So it seems like some internal module (org.apache.commons.io.Charsets) is being imported within the library somewhere.

himat avatar Aug 01 '20 04:08 himat

using npx jetify

lyseiha avatar Aug 04 '20 03:08 lyseiha

@himat by any chance were you able to resolve this error? I seem to be getting it as well

npx jetify did not solve my issue

Edwardp17 avatar Oct 31 '20 19:10 Edwardp17

I created fork to solve this issue. https://github.com/darron1217/react-native-background-geolocation

You can install it by command below

npm install https://github.com/darron1217/react-native-background-geolocation#develop

darron1217 avatar Jan 08 '21 03:01 darron1217

I had same problem with org.apache.commons.io.Charsets. Thank you @darron1217 for whatever you did, it fixed my problem.

menynu avatar Apr 12 '21 07:04 menynu

@darron1217 your module not build release using androidX. Your module it is Symbol problem.

Isaachi1 avatar Nov 24 '22 18:11 Isaachi1