invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.21k forks source link

[🐛] Issue : Failed to transform firebase-encoders-json-18.0.1.aar. , #8010

Closed sahad00 closed 1 month ago

sahad00 commented 1 month ago

Issue

I am encountering this error while trying to build on Android, I mostly found this issue is caused due to crashlytics, please find .json and build. gradle files below

Screenshot 2024-09-09 at 4 56 20 PM

package.json

 "react": "18.3.1",
    "react-native": "0.75.2",
    "react-native-animatable": "^1.3.3",
    "react-native-audio-recorder-player": "3.6.4",
    "react-native-biometrics": "^3.0.1",
    "react-native-branch": "~5.5.0",
    "react-native-calendars": "^1.1304.1",
    "react-native-camera": "^4.2.1",
    "react-native-carrier-info": "^1.1.2",
    "react-native-chart-kit": "^6.12.0",
    "react-native-code-push": "^7.0.4",
    "@react-native-firebase/analytics": "^20.4.0",
    "@react-native-firebase/app": "^20.4.0",
    "@react-native-firebase/auth": "^20.4.0",
    "@react-native-firebase/crashlytics": "^20.4.0",
    "@react-native-firebase/database": "^20.4.0",
    "@react-native-firebase/firestore": "^20.4.0",
    "@react-native-firebase/functions": "^20.4.0",
    "@react-native-firebase/messaging": "^20.4.0",
    "@react-native-firebase/perf": "^20.4.0",
    "@react-native-firebase/remote-config": "^20.4.0",
    "@react-native-firebase/storage": "^20.4.0",

Android

android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 23
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.24"
        androidXAnnotation = "1.2.0"
        androidXBrowser = "1.3.0"
        pdfViewerVersion = "3.2.0-beta.3"
        pdfViewerRepo = "com.github.mhiew"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")

        //Firebase Dependencies
        classpath('com.google.gms:google-services:4.4.2')
        classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
        classpath 'com.google.firebase:perf-plugin:1.4.2'
    }
}

apply plugin: "com.facebook.react.rootproject"

android/app/build.gradle:

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

//Firebase plugins
apply plugin: "com.google.gms.google-services"
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

react {
  autolinkLibrariesWithApp()
}
def enableProguardInReleaseBuilds = true
def jscFlavor = 'org.webkit:android-jsc:+'
dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    implementation 'com.google.firebase:firebase-auth:20.0.3'
    implementation project(':react-native-carrier-info')

    //used in API 34 Android upgrade
    implementation 'org.jetbrains:annotations:16.0.2'  

    implementation 'com.singular.sdk:singular_sdk:12.1.3'
    implementation 'org.codehaus.groovy:groovy-json:3.0.9'

    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.0.0'
    implementation 'com.google.android.gms:play-services-ads-identifier:16+'
    implementation "com.google.firebase:firebase-analytics:18.0.0"
    implementation 'com.google.firebase:firebase-messaging:20.2.4'
    implementation 'com.google.android.exoplayer:exoplayer:2.13.3' //Optional for Audio/Video
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.13.3' //Optional for Audio/Video
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3' //Optional for Audio/Video
    implementation 'com.github.bumptech.glide:glide:4.11.0' //Mandatory for App Inbox
    implementation 'androidx.recyclerview:recyclerview:1.1.0' //Mandatory for App Inbox,
    implementation 'androidx.viewpager:viewpager:1.0.0' //Mandatory for App Inbox
    implementation 'com.google.android.material:material:1.2.1' //Mandatory for App Inbox
    implementation 'androidx.appcompat:appcompat:1.2.0' //Mandatory for App Inbox
    implementation 'androidx.core:core:1.3.0'
    implementation 'androidx.fragment:fragment:1.1.0' // InApp
    //Mandatory for React Native SDK v0.3.9 and above add the following -
    implementation 'com.android.installreferrer:installreferrer:2.2'
    implementation 'com.google.android.gms:play-services-appset:16.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-firestore:21.7.1'
    implementation 'com.airbnb.android:lottie:3.7.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    //Shorcut-Widget-Dependencies-Below
    implementation 'com.google.firebase:firebase-functions:19.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'com.google.firebase:firebase-storage:20.0.1'
    implementation 'com.google.code.gson:gson:2.8.8'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
    implementation 'com.squareup.okhttp3:okhttp:3.6.0'
    //Shorcut-Widget-Dependencies-Above

    // addUnimodulesDependencies()

   if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
    implementation project(':react-native-fs')
    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }  
    implementation 'com.google.android.gms:play-services-base:10.0.1'
    implementation 'com.google.android.gms:play-services-maps:10.0.1'
    implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }
}

android/settings.gradle:

pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'app'
includeBuild('../node_modules/@react-native/gradle-plugin')

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/central' }
        // maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } // Not required as 
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }

        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://www.jitpack.io' }
        maven {
            url("$rootDir/../node_modules/@notifee/react-native/android/libs")
        }
        maven { url 'https://maven.singular.net/' }
        maven { url 'https://mvnrepository.com/artifact/com.google.firebase/firebase-encoders-json' }
    }
}

include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
// apply from: '../node_modules/react-native-unimodules/gradle.groovy'; includeUnimodulesProjects()
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
include ':react-native-carrier-info'
project(':react-native-carrier-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-carrier-info/android')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

gradle-wrapper.properties:

distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

mikehardy commented 1 month ago

it appears that your repository "maven.aliyun.com" for java artifacts needed by gradle does not have all the artifacts

The official google repository has the artifact https://mvnrepository.com/artifact/com.google.firebase/firebase-encoders-json

So this will be a local issue for you, and not an issue for react-native-firebase

sahad00 commented 1 month ago

@mikehardy removed all aliyun.com repo dependency resolved my issue :)