Using react-native-camera with an Expo detached project


#1

Hi,

I have a detached Expo project using ExpoKit. The expo camera is not cutting it for our users so we want to use react-native-camera. I have installed it for iOS and it works. I have got it working in a dev build from Android Studio. But when I try to build an APK using ./gradlew assembleRelease it fails with:

Warning: Exception while processing task java.io.IOException: Can't write [/Users/adriancaroll/workspace/github/underwriter-bot-mobile/android/app/build/intermediates/transforms/proguard/dev19/release/0.jar] 
(Can't read [/Users/adriancaroll/workspace/github/underwriter-bot-mobile/node_modules/react-native-camera/android/build/intermediates/intermediate-jars/release/classes.jar(;;;;;;**.class)] 
(Duplicate zip entry [classes.jar:com/google/android/cameraview/AspectRatio$1.class]))
Thread(Tasks limiter_1): destruction

So, I tried to exclude com.google.android.cameraview but that didn’t work in my android/app/build.gradle:

implementation (project(':react-native-camera')) {
      exclude group: "com.google.android.gms"
      exclude group: "com.google.android.cameraview"
  }

Here is my build.gradle dependencies:

dependencies {
  implementation (project(':react-native-camera')) {
      exclude group: "com.google.android.gms"
      exclude group: "com.google.android.cameraview"
  }
  implementation project(':instabug-reactnative')
  implementation project(':react-native-linear-gradient')
  implementation project(':react-native-i18n')
  implementation project(':react-native-background-upload')
  implementation project(':react-native-fs')
  implementation('io.branch.sdk.android:library:2.17.1@aar') {
        transitive = true;
    }
  implementation('io.fabric.sdk.android:fabric:1.4.2@aar') {
        transitive = true;
    }
  implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
      transitive = true;
    }
  implementation('com.crashlytics.sdk.android:answers:1.4.1@aar') {
        transitive = true;
    }
  implementation fileTree(dir: 'libs', include: ['*.jar'])

  implementation 'com.android.support:multidex:1.0.1'

  // Our dependencies
  // implementation 'com.android.support:appcompat-v7:26.0.1'

  // Our dependencies from ExpoView
  // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
  implementation 'com.android.support:appcompat-v7:26.0.1'
  implementation 'com.facebook.android:facebook-android-sdk:4.7.0'
  implementation('com.facebook.android:audience-network-sdk:4.22.1') {
    exclude module: 'play-services-ads'
  }
  provided 'org.glassfish:javax.annotation:3.1.1'
  implementation 'com.jakewharton:butterknife:7.0.1'
  implementation 'de.greenrobot:eventbus:2.4.0'
  implementation 'com.amplitude:android-sdk:2.9.2' // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
  implementation 'com.squareup.picasso:picasso:2.5.2'
  implementation 'com.google.android.gms:play-services-gcm:9.8.0'
  implementation 'com.google.android.gms:play-services-analytics:9.8.0'
  implementation 'com.google.android.gms:play-services-maps:9.8.0'
  implementation 'com.google.android.gms:play-services-auth:9.8.0'
  implementation 'com.google.android.gms:play-services-location:9.8.0'
  implementation 'com.google.android.gms:play-services-ads:9.8.0'
    annotationProcessor 'com.jakewharton:butterknife:7.0.1'
    annotationProcessor 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
  implementation "com.raizlabs.android:DBFlow-Core:2.2.1"
  implementation "com.raizlabs.android:DBFlow:2.2.1"
  implementation "com.madgag.spongycastle:core:1.53.0.0"
  implementation "com.madgag.spongycastle:prov:1.53.0.0"
  debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  // debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  implementation 'com.facebook.device.yearclass:yearclass:1.0.1'
  implementation 'commons-io:commons-io:1.3.2'
  implementation 'me.leolin:ShortcutBadger:1.1.4@aar'
  implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
  implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
  implementation 'com.yqritc:android-scalablevideoview:1.0.1'
  implementation 'commons-codec:commons-codec:1.10'
  implementation 'com.segment.analytics.android:analytics:4.3.0'
  implementation 'com.google.zxing:core:3.2.1'
  implementation 'net.openid:appauth:0.4.1'
  implementation 'com.airbnb.android:lottie:2.2.0'
  implementation 'io.branch.sdk.android:library:2.6.1'
  implementation('io.nlopez.smartlocation:library:3.2.11') {
    transitive = false
  }
  implementation 'com.android.support:exifinterface:26.0.1'
  implementation 'com.squareup.okhttp3:okhttp:3.4.1'
  implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
  implementation 'com.squareup.okhttp3:okhttp-ws:3.4.1'
  implementation 'com.squareup.okio:okio:1.9.0'

  // Testing
  androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
  // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
  androidTestCompile 'com.android.support.test:runner:1.0.1'
  androidTestCompile 'com.android.support:support-annotations:26.0.1'
  androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
  androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
  androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'



  implementation('host.exp.exponent:expoview:26.0.0@aar') {
    transitive = true
  }
}

When I run ./gradlew app:dependencies > dep.txt I get the following file: https://drive.google.com/open?id=17NVabzxchS5uS9gk4tGPZujXH0eVxjMi


#2

I solved the issue by setting minifyEnabled to false:

  buildTypes {
    debug {
      debuggable true
    }
    release {
      minifyEnabled false

#3

Glad you got it resolved @darkwata!


#4

fwiw, react-native-camera is the expo camera copy+pasted outside of expo


closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.