Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant build my react-native project on android #25313

Closed
tal987 opened this issue Jun 19, 2019 · 12 comments
Closed

Cant build my react-native project on android #25313

tal987 opened this issue Jun 19, 2019 · 12 comments
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@tal987
Copy link

tal987 commented Jun 19, 2019

since yesterday im getting this error when im trying to run my project:

com.android.build.api.transform.TransformException: Error while generating the main dex list.

I was reading some posts about the issue and I tried to add those lines:

android.useAndroidX=true
android.enableJetifier=true

because when I used stack trace I was getting this error:

Program type already present: androidx.versionedparcelable.CustomVersionedParcelable react native

I added this lines to my local.propeties file but when I did that I have seen that I need to change all my node-module files to use androidx

In addition I was trying to update the package react-native-device-info to the newest version 2.1.2 but still the same result...

React Native version:

react-native-cli: 2.0.1
react-native: 0.50.4

I'm working with visual code because my project is for IOS and Android, so the option to migrate to AndroidX is not relevant for me...

I'm attaching my files:

app/build.gradle:

apply plugin: "com.android.application"

 buildscript {
   repositories {
     maven { url 'https://maven.fabric.io/public' }
   }
   dependencies {
     // The Fabric Gradle plugin uses an open ended version to react
     // quickly to Android tooling updates
     classpath 'io.fabric.tools:gradle:1.+'
   }
 }
 apply plugin: 'io.fabric'
 repositories {
   maven { url 'https://maven.fabric.io/public' }
 }
import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

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


def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    dexOptions {
            javaMaxHeapSize "4g"
        }
    defaultConfig {
        applicationId "com.x"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 14
        versionName "2.3.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            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 {
    compile project(':react-native-orientation')
    compile project(':react-native-device-information')
    compile project(':react-native-ble-manager')
    compile project(':react-native-fabric')
    compile project(':react-native-vector-icons')
    compile project(':react-native-spinkit')
    compile project(':react-native-push-notification')
    compile project(':react-native-picker')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-firebase')
    compile project(':react-native-fcm')
    compile project(':react-native-config')
    implementation project(':react-native-picker')
    implementation project(':react-native-device-info')
    implementation project(':react-native-fcm')
    implementation project(':react-native-firebase')
    implementation project(':react-native-svg')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-spinkit')
    implementation project(':react-native-push-notification')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-image-crop-picker')
    implementation project(':react-native-config')
    implementation project(':react-native-picker-module')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.google.android.gms:play-services-gcm:15.0.1"
    implementation "com.android.support:appcompat-v7:28.0.0-rc02"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.0.0' //17.3.1
    implementation 'com.android.support:multidex:1.0.3'
    //implementation 'com.google.firebase:firebase-notifications'
    compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
         transitive = true;
    }

}

// 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'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

android/build.gradle

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

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.1.0'

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

//com.android.ddmlib.DdmPreferences.setTimeOut(50000)

allprojects {
    repositories {
				// Add jitpack repository (added by react-native-spinkit)
				maven { url "https://jitpack.io" }
        mavenLocal()
        google()
        jcenter()
        // maven{
        //     url 'https://maven.google.com'
        // }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

ext {
  compileSdkVersion = 28
  targetSdkVersion = 28
  buildToolsVersion = "28.0.3"
  supportLibVersion = "28.0.0-rc02"
  googlePlayServicesVersion = "15.0.1"
  oreoEXPERIMENTAL = "yes"
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion '28.0.3'
            }
        }
    }
}


my application for androidManifest.xml:

  <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"
      tools:replace="android:appComponentFactory"
      android:appComponentFactory="whateverString"
>

Is there anyway to fix this issue for now? I can't run my project suddenly

@tal987 tal987 added the Bug label Jun 19, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jun 19, 2019
@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the React Native version: section?

If you believe this information is irrelevant to the reported issue, you may write `[skip envinfo]` alongside an explanation in your Environment: section.

@horaciomoreno10
Copy link

horaciomoreno10 commented Jun 19, 2019

I got the same issue

react-native info
info
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 2.84 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.8.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
System Images: android-22 | Intel x86 Atom, android-22 | Google APIs ARM EABI v7a, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: ^16.7.0 => 16.8.6
react-native: 0.59.5 => 0.59.5
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-vector-icons: 4.6.0

@dulmandakh
Copy link
Contributor

@tal987 I would like to advice to upgrade RN to 0.59 because it added 64bit support and Google Play Store will require 64 bit support beginning 1st August 2019. See https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html.

Google's libraries are migrating to AndroidX and causing breakages in apps, see https://developers.google.com/android/guides/releases.

@nghiant96
Copy link

update react-native-device-info to 2.1.2

@tal987
Copy link
Author

tal987 commented Jun 20, 2019

@dulmandakh can you tell me how to update my rn version?

@tal987
Copy link
Author

tal987 commented Jun 20, 2019

@nghiant96 I was mention that I tried that and it didn’t work

@haruelrovix
Copy link

@tal987 month ago I upgraded RN project from 0.55.4 to 0.59.8 successfully.

Here are my primary resources on doing that:

  1. The easiest way to upgrade React Native to the latest version
  2. Facebook official 0.59 release announcement, Upgrading to 0.59.

@tal987
Copy link
Author

tal987 commented Jun 20, 2019

Solution:
for me what that work is this:
#25292 (comment)

hope it will help to others

@lukewlms
Copy link

Same fix for me as for @tal987:

i solved mine with these dependencies

implementation project(':react-native-firebase')
implementation(project(':react-native-push-notification')) {
    exclude group: 'com.google.android.gms'
}
implementation ("com.google.android.gms:play-services-gcm:16.1.0") {
    force = true
}
implementation ("com.google.android.gms:play-services-base:16.1.0") {
    force = true
}
implementation ("com.google.firebase:firebase-core:16.0.9") {
    force = true
}
implementation ("com.google.firebase:firebase-messaging:18.0.0") {
    force = true
}

@ecreeth
Copy link
Contributor

ecreeth commented Jun 28, 2019

@tal987 If the problem was solved, you can close this issue. Thanks!

@stale
Copy link

stale bot commented Sep 26, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 26, 2019
@stale
Copy link

stale bot commented Oct 3, 2019

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

@stale stale bot closed this as completed Oct 3, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

8 participants