streem / react-native-select-contact

A cross-platform contact selection library for react-native
MIT License
114 stars 50 forks source link

[Android] App won't build with RN v0.62.0 #26

Closed bell-steven closed 4 years ago

bell-steven commented 4 years ago

Using react-native-select-contact with RN 0.62 causes a build error on Android. I can reproduce this with version 1.2.1+ (didn't try any of the older versions).

Working on a PR to fix. (I already have a working fork here).

garyp commented 4 years ago

@bell-steven Thanks for the PR! Can you please provide some details on the build error, to help us understand which problem your PR is fixing? We haven't kept up with the newer RN versions internally, so we haven't run into the error ourselves yet.

bell-steven commented 4 years ago

@garyp unfortunately, I couldn't get too much error information beyond this.
Screen Shot 2020-03-29 at 5 32 03 PM I upgraded RN and ran react-native run-android --variant=developmentdebug. (Only an issue on android, not on iOS.)

I did spend some time making sure that react-native-select-contact was indeed the culprit here, and I believe that it is (removing the package allows a build to complete). TBH, I was having a really hard time pinning down what the source of the error was. None of the open PR's seemed to solve it, and the only other thing I can think of of is that android.useDeprecatedNdk=true in the gradle.properties file is the culprit here. (Full disclosure, I am not a native Android dev, I come from a react/web background).

The PR mirrors the android setup from the react-native-share library (which is the basis of this module template). It seems like the android file setup is a couple of years old at this point, and something there is causing the issue.

If you need, I can try and create a minimal repo at some point. Let me know how I can help.

sostenesg7 commented 4 years ago

I'm facing the same issue.

env:

After some hours comparing this library files with other libs, i found a workaround, it's just to build and investigate what is wrong.

I can build now, with success.

what i did:

  1. Move all content of android/app/src to android/src
    • Before android/ |-------app/ |-----------/ src/
  1. replace all content of android/src/main/AndroidManifest.xml to:
    <manifest xmlns:tools="http://schemas.android.com/tools" 
    xmlns:android="http://schemas.android.com/apk/res/android" package="com.streem.selectcontact" android:versionCode="1" android:versionName="1.0">
    <application android:allowBackup="false" tools:replace="android:allowBackup"></application>
    </manifest>
  2. Change all content of android/build.gradle to:
apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 25)
    buildToolsVersion safeExtGet('buildToolsVersion', "25.0.3")

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 25)

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.facebook.react:react-native:+'
}

After that, my project is running. Some commands can be unnecessary above, i just copy and past to see this working.

Mura7 commented 4 years ago

I have same error. image

I tried your branch but didnt work @bell-steven

"react-native": "0.62.1", "react-native-select-contact": "^1.3.2",

sergeylaptev commented 4 years ago

Manually adding

include ':react-native-select-contact'
project(':react-native-select-contact').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-select-contact/android/app')

in android/settings.gradle fixed the issue

Mura7 commented 4 years ago

thanks for reply @sergeylaptev but not fixed added import com.streem.selectcontact.SelectContactPackage;(MainApplication) implementation project(':react-native-select-contact')(android/app/build.gradle) and

include ':react-native-select-contact'
project(':react-native-select-contact').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-select-contact/android/app')

but still have errors. also sometime get this error

Screen Shot 2020-04-08 at 15 11 57
sergeylaptev commented 4 years ago

You don't need anything in the MainApplication. I said to add these 2 rows into the android/settings.gradle:) not the android/app/build.gradle

Mura7 commented 4 years ago

@sergeylaptev Yeah. I tried like you said. Later i added another codes and tried again. But still have a error :)

gregoriohc commented 4 years ago

@sergeylaptev Yeah. I tried like you said. Later i added another codes and tried again. But still have a error :)

Be sure you add it after this line... apply from: file("../node_modules/@react-native-community....

Also, be sure the project line is this one (must include the "/app" at the end): project(':react-native-select-contact').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-select-contact/android/app')

Mura7 commented 4 years ago

tried to your solution @gregoriohc debug is running but get error when create apk

Screen Shot 2020-04-10 at 17 51 00
limoli commented 4 years ago

Any news @bell-steven ?

bell-steven commented 4 years ago

@limoli I created the issue, but I am not a maintainer of this library. It's up to the maintainers to merge any PRs or decide when/how to move forward. In the meantime you can usepatch-package or point to a fork.

anunay commented 4 years ago

having the same issue, can you help how to resolve this: image

FAILURE: Build failed with an exception.

anunay commented 4 years ago

I forked the repo and modifed and this is working fine for me in android and ios, please check the forked repo here. https://github.com/hazesoftco/react-native-select-contact.

so anyone having an issue with android build error, you can just use that repo using yarn add https://github.com/hazesoftco/react-native-select-contact until the author fixed this.

thank you