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

Android SDK BuildToolsVersion and compileSdkVersion update implication #332

Closed
Maxwell2022 opened this issue May 12, 2017 · 14 comments
Closed

Comments

@Maxwell2022
Copy link

I've noticed that 2 months ago the version of the buildToolsVersion has been bumped from 23.0.1 (required version from react-native docs) to 25.0.1, as well as the compileSdkVersion from 23 to 25

The React Native docs specifically says:

Look for and expand the "Android SDK Build Tools" entry, then make sure that Android SDK Build-Tools 23.0.1 is selected.

Someone also tries to submit a PR to react-native project that got rejected with the following comment:

You do indeed need version 23 - the docs are correct..

I'm not sure what is the implication of this and just want to raise it here.
Here is my original comment on the commit:

47a79d3#commitcomment-22096489

@Maxwell2022
Copy link
Author

Ping @lucasbento

@hrm123
Copy link

hrm123 commented Oct 15, 2017

any updates on this? I am unable to use react-native-svg - error:
A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-svg'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 25].

@msand
Copy link
Collaborator

msand commented Oct 15, 2017

At least I'm able to use v25 just fine in both dev and prod builds. Have you tried opening the android project in android studio and install v25?

@hrm123
Copy link

hrm123 commented Oct 15, 2017

am able to use v25 too.. just bothers me that react native suggests to use v23

@nol13
Copy link

nol13 commented Jan 22, 2018

Am I missing something? Seems like big issue to force people off the version that RN requires for a RN lib.

@msand
Copy link
Collaborator

msand commented Jan 22, 2018

How is it an issue? Or a requirement? More like an outdated suggestion from their part. E.g. react-native-fbsdk use SDK 26 and appcompat-v7:27.0.2
At least I consider google more relevant than facebook regarding what versions of native code to use when building for android.

@nol13
Copy link

nol13 commented Jan 23, 2018

Guess I just assumed that if they explicitly said version 23, they must have at least some reasoning behind it. Not well versed in the implications of changing sdk versions, so really wasn't looking to mess with the defaults if at all possible. RN not the most stable environment ever as is.

@msand
Copy link
Collaborator

msand commented Jan 23, 2018

That's true. But at least I've been running (all?) the newer version without issues, as long as the appcompat matches.

@msand
Copy link
Collaborator

msand commented Jan 26, 2018

I've made a PR to react-native and the docs. So now you have a source telling you to upgrade, to address a Path Traversal Vulnerability.
https://deploy-preview-156--react-native.netlify.com/docs/next/getting-started.html#android-development-environment

#581 (comment)

lepouya commented 8 hours ago
@msand It's the same versions as why facebook-android-sdk uses

facebook/react-native#17752

facebook/react-native#17747

facebook/react-native-website#156

@msand
Copy link
Collaborator

msand commented Feb 3, 2018

@hrm123 @nol13 @Maxwell2022 I've released a new version, which aligns with react-native init, to make it as easy as possible for newcomers. Anyone with needs to upgrade any versions to anything different from that, will hopefully learn how to change them in their dependencies in the process as well. Lets see if they upgrade any versions, now that a PR exists. Can release a new version to align with that when they do.

@msand msand closed this as completed Feb 13, 2018
@msand
Copy link
Collaborator

msand commented Feb 15, 2018

It seems facebook themselves are running appcompat 27.0.2 internally, which i guesss means they compile against SDK 27. I think manually updating these versions to the latest ones, is the way to go, for anyone who wants to use the latest patches for security, performance etc. Using outdated versions because some more than one year old documentation suggests so, probably shouldn't be best practice. Especially when up to date sources explicitly say to use the latest available. Keeping it maximally convenient for beginners makes sense as well, thus having react-native init use the latest ones is what should actually change.

@Billy-
Copy link

Billy- commented Apr 6, 2018

I have been getting this error message and have been unable to make it go away, no matter what I tried. In the end, downgrading react-native-svg to 5.x got rid of the issue for me.

@msand
Copy link
Collaborator

msand commented Apr 9, 2018

@Billy- Interesting, they should be aligned with react-native in the latest version. Can you provide your android/app/build.gradle file? The appcompat dependency has been removed as well, so it should build with almost any combination now.

@Billy-
Copy link

Billy- commented Apr 10, 2018

Unfortunately I have opted to go without shadows (this was being installed as a dependency of react-native-shadows) for now - but will revisit it later. However, here is our gradle file, it has mostly been reverted back to what was being used before I started trying to get this to work.

android/app/build.gradle
apply plugin: "com.android.application"

import com.android.build.OutputFile
import groovy.json.JsonSlurper

def getNpmVersion() {
    def inputFile = new File("../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)
    return packageJson["version"]
}

def getVersionCode() {
    def npmVersion = getNpmVersion()
    def (major, minor, patch) = npmVersion.tokenize('.')
    return (major.toInteger() * 1000000) + (minor.toInteger() * 10000) + (patch.toInteger() * 100).toInteger()
}

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

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

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.github.triplet.play'

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = true

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

def androidVersionCode = getVersionCode()
def androidVersionName = getNpmVersion()

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.3"

    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "8g"
    }
    signingConfigs {
        release {
            if (System.getenv("MOBILE_RELEASE_STORE_FILE")) {
                storeFile file(System.getenv("MOBILE_RELEASE_STORE_FILE"))
                storePassword System.getenv("MOBILE_RELEASE_STORE_PASSWORD")
                keyAlias System.getenv("MOBILE_RELEASE_KEY_ALIAS")
                keyPassword System.getenv("MOBILE_RELEASE_KEY_PASSWORD")
            }
        }
    }
    playAccountConfigs {
        defaultAccountConfig {
            serviceAccountEmail = System.getenv('SERVICE_ACCOUNT')
            jsonFile = file('*obfuscated*')
        }
    }
    play {
        track = 'alpha' // or 'rollout' or 'beta' or 'alpha'
        // userFraction = 0.2 // only necessary for 'rollout', in this case default is 0.1 (10% of the target)
    }
    defaultConfig {
        applicationId "*obfuscated*"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode androidVersionCode
        versionName androidVersionName
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        playAccountConfig = playAccountConfigs.defaultAccountConfig
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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-maps')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
//    classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
}

// 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'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants