Skip to content

Commit ba433c0

Browse files
committed
Support gradle < 7.3.0
1 parent be81e6e commit ba433c0

6 files changed

Lines changed: 67 additions & 54 deletions

File tree

android/app/build.gradle

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,71 @@
11
apply plugin: "com.android.library"
22

3-
def DEFAULT_COMPILE_SDK_VERSION = 26
4-
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"
5-
def DEFAULT_TARGET_SDK_VERSION = 26
6-
def DEFAULT_MIN_SDK_VERSION = 16
3+
def getExtOrDefault(name) {
4+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["CodePush_" + name]
5+
}
6+
7+
def getExtOrIntegerDefault(name) {
8+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["CodePush_" + name]).toInteger()
9+
}
10+
11+
def supportsNamespace() {
12+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
13+
def major = parsed[0].toInteger()
14+
def minor = parsed[1].toInteger()
15+
16+
// Namespace support was added in 7.3.0
17+
return (major == 7 && minor >= 3) || major >= 8
18+
}
719

820
android {
21+
if (supportsNamespace()) {
922
namespace "com.appzung.codepush.react"
1023

11-
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
12-
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
13-
14-
defaultConfig {
15-
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
16-
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
17-
versionCode 1
18-
versionName "1.0"
24+
sourceSets {
25+
main {
26+
manifest.srcFile "src/main/AndroidManifestNew.xml"
27+
}
1928
}
29+
}
2030

21-
lintOptions {
22-
abortOnError false
23-
}
31+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
2432

25-
defaultConfig {
26-
consumerProguardFiles 'proguard-rules.pro'
33+
defaultConfig {
34+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36+
37+
consumerProguardFiles 'proguard-rules.pro'
38+
}
39+
40+
buildFeatures {
41+
buildConfig true
42+
}
43+
44+
buildTypes {
45+
release {
46+
minifyEnabled false
2747
}
48+
}
49+
50+
lintOptions {
51+
disable "GradleCompatible"
52+
}
53+
54+
compileOptions {
55+
sourceCompatibility JavaVersion.VERSION_1_8
56+
targetCompatibility JavaVersion.VERSION_1_8
57+
}
58+
}
59+
60+
repositories {
61+
mavenCentral()
62+
google()
2863
}
2964

3065
dependencies {
31-
implementation "com.facebook.react:react-native:+"
32-
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
66+
// For < 0.71, this will be from the local maven repo
67+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
68+
//noinspection GradleDynamicVersion
69+
implementation "com.facebook.react:react-native:+"
70+
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
3371
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2-
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.appzung.codepush.react">
33
<uses-permission android:name="android.permission.INTERNET" />
4-
54
</manifest>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET" />
3+
</manifest>

android/build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,9 @@ buildscript {
66
mavenCentral()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:1.3.0'
9+
classpath "com.android.tools.build:gradle:7.2.1"
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files
1313
}
1414
}
15-
16-
allprojects {
17-
android {
18-
namespace "com.appzung.codepush.react"
19-
}
20-
repositories {
21-
mavenLocal()
22-
mavenCentral()
23-
}
24-
}

android/gradle.properties

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# Project-wide Gradle settings.
2-
3-
# IDE (e.g. Android Studio) users:
4-
# Gradle settings configured through the IDE *will override*
5-
# any settings specified in this file.
6-
7-
# For more details on how to configure your build environment visit
8-
# http://www.gradle.org/docs/current/userguide/build_environment.html
9-
10-
# Specifies the JVM arguments used for the daemon process.
11-
# The setting is particularly useful for tweaking memory settings.
12-
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13-
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14-
15-
# When configured, Gradle will run in incubating parallel mode.
16-
# This option should only be used with decoupled projects. More details, visit
17-
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
19-
20-
android.useDeprecatedNdk=true
1+
CodePush_minSdkVersion=16
2+
CodePush_targetSdkVersion=31
3+
CodePush_compileSdkVersion=31
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

0 commit comments

Comments
 (0)