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.65k stars 2.21k forks source link

[ANDROID][FIREBASE V6]transformClassesAndResourcesWithR8ForRelease FAILED - Shrinker (R8) #3274

Closed humbertoromanojr closed 4 years ago

humbertoromanojr commented 4 years ago

Issue

Describe your issue here

As I am new to this help pattern for reporting Build errors, so I'm sorry if I was wrong to repost this bug here.

I already did as suggested in => 'android.enableR8 = false' and I was not successful and I also commented where there is => io.invertase.firebase.admob.BuildConfig and the same thing, the error still continues.

More in the normal degub, I managed to get Admob to work perfectly, but when I try to do Realease from APK it gives this error. because I am using the latest version of React Native.

Tutorial used to install Firebase and admob => https://invertase.io/oss/react-native-firebase/v6/admob/quick-start

===========bug R8 is the new Android code shrinker. If you experience any issues, please file a bug at https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can disable R8 by updating gradle.properties with 'android.enableR8=false'. Current version is: 1.4.94 (build 390954928f0db9c3b888a367f7f128ce3bbfb160 from go/r8bot (luci-r8-ci-archive-0-5g74)).

D8: Program type already present: io.invertase.firebase.admob.BuildConfig

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings


Project Files

buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 21 compileSdkVersion = 28 targetSdkVersion = 28 } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.4.2")

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { mavenLocal() 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") } maven { url("$rootDir/../node_modules/react-native/android") }

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

}

project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ]

apply from: "../../node_modules/react-native/react.gradle"

/**

/**

/**

/**

android { compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.jrdevportfolio"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 3
    versionName "3.0"

}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
            storeFile file(MYAPP_UPLOAD_STORE_FILE)
            storePassword MYAPP_UPLOAD_STORE_PASSWORD
            keyAlias MYAPP_UPLOAD_KEY_ALIAS
            keyPassword MYAPP_UPLOAD_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk true  // If true, also generate a universal APK
        include "armeabi-v7a", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.release
        shrinkResources true
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }

    }
}

}

dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules

implementation 'androidx.appcompat:appcompat:1.1.0-rc01' // navigation
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

implementation 'com.facebook.fresco:fresco:2.0.0'
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.0.0'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:2.0.0'
implementation 'com.facebook.fresco:webpsupport:2.0.0'

implementation project(path: ":@react-native-firebase_app")
implementation project(path: ":@react-native-firebase_admob")
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation "com.google.firebase:firebase-ads:17.2.1"
implementation 'com.google.firebase:firebase-analytics:17.2.2'

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

}

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }

project.ext.vectoricons = [ iconFontNames: [ 'MaterialIcons.ttf' ] // Name of the font files you want to copy ] apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myportfolio">

<uses-permission android:name="android.permission.INTERNET" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

Javascript

Click To Expand

#### `package.json`: ```json { "name": "myportfolio", "version": "0.0.1", "private": true, "scripts": { "restart": "rm -rf node_modules && rm -rf /tmp/haste-map-react-native-packager-* && yarn install && react-native start --reset-cache", "dev": "yarn react-native run-android", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-community/async-storage": "^1.8.0", "@react-native-community/masked-view": "^0.1.6", "@react-native-firebase/admob": "^6.3.4", "@react-native-firebase/app": "^6.3.4", "axios": "^0.19.2", "date-fns": "^2.10.0", "date-fns-tz": "^1.0.10", "native-base": "^2.13.8", "react": "16.9.0", "react-native": "0.61.5", "react-native-banner-carousel": "^1.0.3", "react-native-email": "^1.0.2", "react-native-gesture-handler": "^1.6.0", "react-native-i18n": "^2.0.15", "react-native-linear-gradient": "^2.5.6", "react-native-platform-touchable": "^1.1.1", "react-native-reanimated": "^1.7.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.2.0", "react-native-snap-carousel": "^3.8.4", "react-native-vector-icons": "^6.6.0", "react-native-webview": "^8.1.2", "react-navigation": "^4.2.1", "react-navigation-drawer": "^2.4.1", "react-navigation-stack": "^2.2.1", "react-redux": "^7.2.0", "redux": "^4.0.5", "styled-components": "^5.0.1" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^0.0.7", "babel-jest": "^25.1.0", "eslint": "^6.8.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.58.0", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [x] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [x] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

mikehardy commented 4 years ago

I can't reproduce, and I build release mode in my tests https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh#L161

stale[bot] commented 4 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

ezel3050 commented 3 years ago

For anyone who still has this issue: 1- check custom Gradle properties in publishing settings 2- in Gradle.properties (located in Plugins/android) set the value of android.enableR8 to false just like this: android.enableR8=false 3- do the Force resolution thing and you are good to go.