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

RN 0.47 seems to be working fine with gradle 4.0 and compileSdkVersion / buildToolsVersion 26 #15448

Closed
pocesar opened this issue Aug 10, 2017 · 24 comments
Labels
Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.

Comments

@pocesar
Copy link

pocesar commented Aug 10, 2017

The build went from 6 minutes (for a 35 file project) down to 24s, on a second wind after the gradle daemon has already started with at least 1500MB memory...

Maybe encourage new projects to use those optimized settings, since I'm also using a lot of third party android Java modules, with no incompatibilities issues.

my build.gradle looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
    compileSdkVersion = 26 // Or what version you want (latest is recommended)
    buildToolsVersion = '26.0.1' // same thing
}

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.+'

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

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip

in build.gradle inside app folder

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    // ...

also, I was this settings since 0.46, and react-native-git-upgrade without any issues as well

@kelset
Copy link
Contributor

kelset commented Aug 10, 2017

Are you using these settings for an app out in production?

@pocesar
Copy link
Author

pocesar commented Aug 10, 2017

yes, I am, and also using with code-push

@kelset
Copy link
Contributor

kelset commented Aug 10, 2017

Interesting, how long have you been using these settings? Is it performing well in Android 7?

Since I've upped to 25 (both compile and buildtools) some users have crashes I don't know how to debug (#15429) on Nougat.

And, follow-up, if you submit to the Google Play Store a build targetting 26, can you reverse to 25? 'cause I know you can't when upping from 23 to 25 it's a "no turning back" point.

@pocesar
Copy link
Author

pocesar commented Aug 10, 2017

well, I'm not using Google Play, so I'm not sure. I'm testing on Samsung J7 with Android 6.0.1 and Android 7 as well, both seems to be working fine with a lot of intricate third party modules (like react-native-maps, react-native-camera, etc)

That error doesn't seem to be a problem with the buildTools per se, but it might be related to the SDK version, and guess it might be some bugs since it's the 'edge' of the Android SDKs (a quick googling showed that is a pretty common error on native Android using Java, even without react-native)

@iegik
Copy link

iegik commented Aug 23, 2017

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip

Still have issues:
#14980

@kelset
Copy link
Contributor

kelset commented Aug 23, 2017

Ok, I've tried to update my app too to 26 settings provided above, everything seems to be running fine for now.

I think tbh this issue could be closed, anyway, because it's not really "an issue".

@iegik
Copy link

iegik commented Aug 23, 2017

Ok. But I still cannot say that RN is stable.

http://services.gradle.org/versions/current

@agrass
Copy link

agrass commented Aug 28, 2017

it is not recommended to use compileSdkVersion 26 on production?? What do you guys think?

@iegik
Copy link

iegik commented Aug 28, 2017

Some braking changes not resolved in Android Oreo (7+, 8.0.0):

@pocesar
Copy link
Author

pocesar commented Aug 28, 2017

@agrass I think you mean targetSdkVersion you can set that regardless of the compileSdkVersion (usually 23)

@agrass
Copy link

agrass commented Aug 28, 2017

@pocesar I have targetSdkVersion 22, and I changed the buildToolsVersion and compileSdkVersion from 23 to 26 in order to use a library with some dependencies. Now I'm a bit scared about this, because I'm not sure about the compatibility in some phones building RN with v26. Probably I'm going to roll back to v23

@agrass
Copy link

agrass commented Aug 29, 2017

thanks @iegik for the references. what about v25, it is the same??

@iegik
Copy link

iegik commented Aug 29, 2017

25 - more stable

    defaultConfig {
        applicationId "com.acme.app"
        // An integer designating the minimum API Level required for the application to run.
        // The Android system will prevent the user from installing the application if the system's API Level
        // is lower than the value specified in this attribute. You should always declare this attribute.
        minSdkVersion 16
        // This attribute informs the system that you have tested against the target version
        // and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility
        // with the target version. The application is still able to run on older versions (down to minSdkVersion).
        // FIXME: Support Android Oreo (7+, 8.0.0)
        targetSdkVersion 25
        // An integer designating the maximum API Level on which the application is designed to run.
        // maxSdkVersion ??
        versionCode 1
        versionName "${packageJSON.version}"
        ndk {
            // Test all dependences on x64 devices (might not work)
            // https://github.com/facebook/react-native/issues/2814
            abiFilters 'armeabi-v7a', 'x86'
        }
        // Enabling multidex support.
        // https://stackoverflow.com/questions/41426853/java-lang-classnotfoundexception-in-dalvik-system-basedexclassloader-findclass
        multiDexEnabled true
        packagingOptions {
            exclude "lib/arm64-v8a/librealm-jni.so"
        }
    }

@agrass
Copy link

agrass commented Aug 30, 2017

thanks, but suitable for production?? Anyone already using it?

@iegik
Copy link

iegik commented Sep 6, 2017

I would not to promote stable release since of https://github.com/facebook/react-native/releases/tag/v0.40.0 because:

@kelset
Copy link
Contributor

kelset commented Sep 6, 2017

thanks, but suitable for production?? Anyone already using it?

I've been using 25 in prod and it's mostly stable, aside from an Android 7 issue.

@stale
Copy link

stale bot commented Nov 5, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. 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 Nov 5, 2017
@pocesar
Copy link
Author

pocesar commented Nov 5, 2017

not many tests were done in recente android sdk versions. Google itself ask to always use the latest SDK versions, and RN is still stuck in 23 by default. Maybe create a matrix testing for the CI?

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 5, 2017
@kelset
Copy link
Contributor

kelset commented Nov 6, 2017

I think this should remain open, currently I'm trying to use version 26 on our prod app and I'm facing some weird issues only when I test the app on Android 8.

@stale
Copy link

stale bot commented Jan 5, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. 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 Jan 5, 2018
@pocesar
Copy link
Author

pocesar commented Jan 5, 2018

#17287 shows urgency on the issue

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 5, 2018
@react-native-bot react-native-bot added Android Resolution: PR Submitted A pull request with a fix has been provided. labels Mar 9, 2018
samuel-h-r-nunes added a commit to team-r3/r3 that referenced this issue May 17, 2018
* Updated packages:
  * react: ^16.3.2 (was ^16.3.0-alpha.1)
  * react-native: ^0.54.4 (was ^0.54.4)
  * native-base: "^2.4.4 (was ^2.4.2)
  * redux: ^4.0.0 (was ^3.7.2)
  * react-test-renderer: ^16.3.2 (was 16.3.0-alpha.3)
  * NOTE: I read the update notes and these should be safe changes,
    including "redux", which got a major version update.

* Gradle-related changes:
  * Changed the way how the SDK is defined in the Gradle configuration:
    Now this is configured globally in `/android/build.gradle`, which
    gets rid of the version warnings.
  * Updated Gradle to version 4.4 (was 4.1).
  * Updated the Gradle plugin to version 3.1 (was 3.0.1).

INSTALLATION STEPS:
===================
rm package-lock.json
rm node_modules
npm install --no-optional  // (NOTE: "--no-optional" needed on Windows)

TROUBLESHOOTING:
================
* If there are any errors like "could not delete folder x", remove those
  folders manually, e.g.:
    rm C:\r3\android\app\build\intermediates\incremental\processDebugResources
    rm C:\r3\android\app\build\generated\source\r\debug\org\webkit

* If there are errors like "unable to create folder x", try again. It
  should work on the second time.

READ
====
* Main motivation:
  * We should have an SDK version which is at least v26, since that will
    be the minimum to be accepted in the Play store after August 2018:
      facebook/react-native#17287
      facebook/react-native#19297
  * Regarding Gradle, the latest versions are required to build for the
    lastest SDKs, but will also increase compilation time a lot:
      facebook/react-native#15448

* React Native Maps installation and Gradle upgrade instructions:
    https://itnext.io/install-react-native-maps-with-gradle-3-on-android-44f91a70a395

* Migration instructions for the Android Gradle Plugin v3.0.0:
    https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration

* List of versions of the Android Gradle Plugin and upgrade steps:
    https://developer.android.com/studio/releases/gradle-plugin
@nerdmed
Copy link

nerdmed commented May 25, 2018

Any news on this? Updating Gradle makes our Android builds 50x faster. That is really significant and would benefit the developer experience!

@slorber
Copy link
Contributor

slorber commented Jul 3, 2018

Hey, just wanted to point out that when ejecting from Expo, you already use SDK26. Many of us have SDK26 Expo ejected apps in production (I have one, Expo SDK22, Android SDK26), so I guess it should be safe to target SDK26. I've been fine with Gradle 4.1.

@dulmandakh
Copy link
Contributor

Closing this issue, because RN 0.57 will have SDK 27, Support library 27.x, gradle 4.x and android gradle plugin 3.x

@facebook facebook locked as resolved and limited conversation to collaborators Dec 11, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.
Projects
None yet
Development

No branches or pull requests

9 participants