EvanBacon / expo-native-firebase

🔥 Native Firebase Expo App (iOS, Android) Demo for Firestore, Notifications, Analytics, Storage, Messaging, Database 🚨
211 stars 41 forks source link

NoSuchMethodError on android #3

Closed ethanyuwang closed 5 years ago

ethanyuwang commented 6 years ago

screenshot_1518045351

I have followed the tutorial and it works fine on iOS but received the above error. I have asked the same question on RNFirebase and they said it's because the version of the google play services libraries (9.8.0) doesn't have that method. (https://github.com/invertase/react-native-firebase/issues/818)

So I downgraded RNFirebase to 3.2.0 and even 3.0.0 but still having the same problem. I saw in your project's package.json you're using "^3.2.2" so I suppose that wasn't the case.

Also, some people mentioned it could be due to unmatching versions of google play service and firebase mine are all of the same version of '9.8.0'

my app/build.graddle:

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'

repositories {
  maven { url 'https://maven.fabric.io/public' }
}

android {
  compileSdkVersion 26
  buildToolsVersion '26.0.2'

  defaultConfig {
    applicationId 'com.resure.glever'
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 5
    versionName '0.9.5'
    ndk {
      abiFilters 'armeabi-v7a', 'x86'
    }
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    // Deprecated. Used by net.openid:appauth
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'host.exp.exponent'
    ]
  }
  dexOptions {
    javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
  }

  // Specifies two flavor dimensions.
  flavorDimensions "dev"

  productFlavors {
    // Define separate dev and prod product flavors.
    dev {
      // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
      // to pre-dex each module and produce an APK that can be tested on
      // Android Lollipop without time consuming dex merging processes.
      dimension "dev"
      minSdkVersion 21
    }

  }
  buildTypes {
    debug {
      debuggable true
    }
    release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      zipAlignEnabled true
    }
  }
    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
        devRelease {
            storeFile file('../debug.keystore')
        }
    }
  lintOptions {
    abortOnError false
  }
}

// Don't use modern jsc-android since it still has some critical bugs that
// crash applications when the string for the JS bundle is loaded and when
// locale-specific date functions are called.
// configurations.all {
//   resolutionStrategy {
//     force 'org.webkit:android-jsc:r216113'
//   }
// }

task exponentPrebuildStep(type: Exec) {
  workingDir '../'
  if (System.getProperty('os.name').toLowerCase().contains('windows')) {
    commandLine 'cmd', '/c', '.\\detach-scripts\\prepare-detached-build.bat'
  } else {
    commandLine './detach-scripts/prepare-detached-build.sh'
  }
}
preBuild.dependsOn exponentPrebuildStep

dependencies {

    compile(project(':react-native-firebase')) {
        transitive = false
    }
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    // Our dependencies
    compile '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.
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile('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:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.amplitude:android-sdk:2.9.2'
    // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-gcm:9.8.0'
    compile 'com.google.android.gms:play-services-analytics:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-auth:9.8.0'
    compile 'com.google.android.gms:play-services-location:9.8.0'
    compile 'com.google.android.gms:play-services-ads:9.8.0'
    compile 'com.google.android.gms:play-services-base:9.8.0'
    compile 'com.google.firebase:firebase-core:9.8.0'
    compile 'com.google.firebase:firebase-analytics:9.8.0'
    annotationProcessor 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
    compile 'com.raizlabs.android:DBFlow-Core:2.2.1'
    compile 'com.raizlabs.android:DBFlow:2.2.1'
    compile 'com.madgag.spongycastle:core:1.53.0.0'
    compile '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'
    compile 'com.facebook.device.yearclass:yearclass:1.0.1'
    compile 'commons-io:commons-io:1.3.2'
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
    compile 'com.yqritc:android-scalablevideoview:1.0.1'
    compile 'commons-codec:commons-codec:1.10'
    compile 'com.segment.analytics.android:analytics:4.3.0'
    compile 'com.google.zxing:core:3.2.1'
    compile 'net.openid:appauth:0.4.1'
    compile 'com.airbnb.android:lottie:2.2.0'
    compile 'io.branch.sdk.android:library:2.6.1'
    compile('io.nlopez.smartlocation:library:3.2.11') {
        transitive = false
    }
    compile 'com.android.support:exifinterface:26.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
    compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
    compile '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'
    compile('host.exp.exponent:expoview:25.0.0@aar') {
        transitive = true
    }
}

// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'

my project gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.2'
    classpath 'de.undercouch:gradle-download-task:2.0.0'
    classpath 'com.google.firebase:firebase-plugins:1.1.1'
  }
}

allprojects {
  repositories {
    google()
    maven {
      url "$rootDir/maven"
    }
    maven {
      // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
      url "$rootDir/maven-test"
    }
    jcenter()
    maven {
      // Local Maven repo containing AARs with JSC built for Android
      url "$rootDir/../js/node_modules/jsc-android/android"
    }
    flatDir {
      dirs 'libs'
      // dirs project(':expoview').file('libs')
    }
    maven { url "https://jitpack.io" }
    maven {
      url 'https://maven.google.com'
    }

    // Want this last so that we never end up with a stale cache
    mavenLocal()
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}
EvanBacon commented 5 years ago

full rewrite, resolved :)