Skip to content

Commit

Permalink
[go] add android sdk49 versioned code (expo#23110)
Browse files Browse the repository at this point in the history
# Why

for sdk 49

# How

- [go] add android sdk 49 versioned code
- [tools] minor fix for android versioning

# Test Plan

ci passed
  • Loading branch information
Kudo authored Jun 27, 2023
1 parent 5742532 commit 4440fb5
Show file tree
Hide file tree
Showing 1,963 changed files with 226,020 additions and 5 deletions.
5 changes: 5 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ dependencies {
// ADD_NEW_SDKS_HERE


// BEGIN_SDK_49
versionedImplementation(project(':expoview-abi49_0_0'))
// END_SDK_49


// BEGIN_SDK_48
versionedImplementation(project(':expoview-abi48_0_0'))
// END_SDK_48
Expand Down
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ allprojects {
url "$rootDir/maven"
}
// For old expoviews to work
maven {
url "$rootDir/versioned-abis/expoview-abi49_0_0/maven"
}
maven {
url "$rootDir/versioned-abis/expoview-abi48_0_0/maven"
}
Expand Down
3 changes: 3 additions & 0 deletions android/expoview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ dependencies {

// Versioned react native
// THIS COMMENT IS USED BY android-build-aar.sh DO NOT MODIFY
// BEGIN_SDK_49
versionedApi 'host.exp:reactandroid-abi49_0_0:1.0.0'
// END_SDK_49
// BEGIN_SDK_48
versionedApi 'host.exp:reactandroid-abi48_0_0:1.0.0'
// END_SDK_48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public static void setSdkVersions(List<String> sdkVersions) {
// WHEN_DISTRIBUTING_REMOVE_FROM_HERE
// WHEN_PREPARING_SHELL_REMOVE_FROM_HERE
// ADD ABI VERSIONS HERE DO NOT MODIFY
// BEGIN_SDK_49
abiVersions.add("49.0.0");
// END_SDK_49
// BEGIN_SDK_48
abiVersions.add("48.0.0");
// END_SDK_48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class MultipleVersionReactNativeActivity extends ReactNativeActivity impl
abi48_0_0.com.facebook.react.modules.core.DefaultHardwareBackBtnHandler,
abi48_0_0.com.facebook.react.modules.core.PermissionAwareActivity,
// END_SDK_48
// BEGIN_SDK_49
abi49_0_0.com.facebook.react.modules.core.DefaultHardwareBackBtnHandler,
abi49_0_0.com.facebook.react.modules.core.PermissionAwareActivity,
// END_SDK_49
// ADD_NEW_SDKS_HERE
// WHEN_PREPARING_SHELL_REMOVE_TO_HERE
// WHEN_DISTRIBUTING_REMOVE_TO_HERE
Expand All @@ -34,6 +38,12 @@ public void requestPermissions(String[] strings, int i, abi48_0_0.com.facebook.r
super.requestPermissions(strings, i, permissionListener::onRequestPermissionsResult);
}
// END_SDK_48
// BEGIN_SDK_49
@Override
public void requestPermissions(String[] strings, int i, abi49_0_0.com.facebook.react.modules.core.PermissionListener permissionListener) {
super.requestPermissions(strings, i, permissionListener::onRequestPermissionsResult);
}
// END_SDK_49
// ADD_NEW_PERMISSION_AWARE_ACTIVITY_IMPLEMENTATION_HERE
// WHEN_PREPARING_SHELL_REMOVE_TO_HERE
// WHEN_DISTRIBUTING_REMOVE_TO_HERE
Expand Down
2 changes: 1 addition & 1 deletion android/sdkVersions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sdkVersions":["47.0.0","48.0.0"]}
{"sdkVersions":["47.0.0","48.0.0","49.0.0"]}
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ project(":expo-random").projectDir = new File("../packages/expo-random/android")

[
// ADD_NEW_SUPPORTED_ABIS_HERE
"abi49_0_0",
"abi48_0_0",
"abi47_0_0",
].forEach({ abiVariant ->
Expand All @@ -51,5 +52,6 @@ useExpoModules([
])

useVendoredModulesForSettingsGradle('unversioned')
useVendoredModulesForSettingsGradle('sdk49')
useVendoredModulesForSettingsGradle('sdk48')
useVendoredModulesForSettingsGradle('sdk47')
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import java.nio.file.Paths

def resolveModulePath(packageName) {
def basePath = rootDir.toPath().normalize()

// Node's module resolution algorithm searches up to the root directory,
// after which the base path will be null
while (basePath) {
def candidatePath = Paths.get(basePath.toString(), 'node_modules', packageName)
if (candidatePath.toFile().exists()) {
return candidatePath.toString()
}

basePath = basePath.getParent()
}

return null
}

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

def getFlagOrDefault(flagName, defaultValue) {
rootProject.hasProperty(flagName) ? rootProject.properties[flagName] == "true" : defaultValue
}

def getVersionOrDefault(String flagName, String defaultVersion) {
rootProject.hasProperty(flagName) ? rootProject.properties[flagName] : defaultVersion
}

configurations {
compileClasspath
}

buildscript {
// kotlin version is dictated by rootProject extension or property in gradle.properties
ext.asyncStorageKtVersion = rootProject.ext.has('kotlinVersion')
? rootProject.ext['kotlinVersion']
: rootProject.hasProperty('AsyncStorage_kotlinVersion')
? rootProject.properties['AsyncStorage_kotlinVersion']
: '1.8.10'

repositories {
mavenCentral()
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$asyncStorageKtVersion"
}
}

// AsyncStorage has default size of 6MB.
// This is a sane limit to protect the user from the app storing too much data in the database.
// This also protects the database from filling up the disk cache and becoming malformed.
// If you really need bigger size, please keep in mind the potential consequences.
long dbSizeInMB = 6L
def newDbSize = rootProject.properties['AsyncStorage_db_size_in_MB']
if (newDbSize != null && newDbSize.isLong()) {
dbSizeInMB = newDbSize.toLong()
}

// Instead of reusing AsyncTask thread pool, AsyncStorage can use its own executor
def useDedicatedExecutor = getFlagOrDefault('AsyncStorage_dedicatedExecutor', false)

// Use next storage implementation
def useNextStorage = getFlagOrDefault("AsyncStorage_useNextStorage", false)

apply plugin: 'com.android.library'
if (useNextStorage) {
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply from: './testresults.gradle'
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 32)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 23)
targetSdkVersion safeExtGet('targetSdkVersion', 32)
buildConfigField "Long", "AsyncStorage_db_size", "${dbSizeInMB}L"
buildConfigField "boolean", "AsyncStorage_useDedicatedExecutor", "${useDedicatedExecutor}"
buildConfigField "boolean", "AsyncStorage_useNextStorage", "${useNextStorage}"
}
lintOptions {
abortOnError false
}

if (useNextStorage) {
testOptions {
unitTests {
returnDefaultValues = true
includeAndroidResources = true
}
}
}
}

repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "${resolveModulePath("react-native")}/android"
}
google()
mavenCentral()
}

dependencies {

if (useNextStorage) {
def room_version = getVersionOrDefault('AsyncStorage_next_roomVersion', '2.4.3')
def coroutines_version = "1.6.4"
def coroutinesTest_version = "1.6.4"
// if we don't provide explicit dependency on reflection, kotlin plugin
// would add one automatically, probably a version that is not compatible with
// used kotlin
def kotlinReflect_version = project.ext.asyncStorageKtVersion
def junit_version = "4.13.2"
def robolectric_version = "4.7.3"
def truth_version = "1.1.3"
def androidxtest_version = "1.4.0"
def androidtest_junit_version = "1.1.3"

implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinReflect_version"

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
kapt "androidx.room:room-compiler:$room_version"

testImplementation "junit:junit:$junit_version"
testImplementation "androidx.test:runner:$androidxtest_version"
testImplementation "androidx.test:rules:$androidxtest_version"
testImplementation "androidx.test.ext:junit:$androidtest_junit_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
testImplementation "com.google.truth:truth:$truth_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesTest_version"
}

//noinspection GradleDynamicVersion
implementation 'host.exp:reactandroid-abi49_0_0:1.0.0'
compileOnly 'com.facebook.fbjni:fbjni:+'
compileOnly 'com.facebook.yoga:proguard-annotations:+'
compileOnly 'com.facebook.soloader:soloader:+'
compileOnly 'com.facebook.fresco:fbcore:+'
compileOnly 'com.facebook.infer.annotation:infer-annotation:+'
compileOnly 'androidx.annotation:annotation:+'
compileOnly 'com.google.code.findbugs:jsr305:+'
compileOnly 'androidx.appcompat:appcompat:+'
compileOnly 'androidx.swiperefreshlayout:swiperefreshlayout:+'
// From node_modules
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
android.useAndroidX=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="abi49_0_0.com.reactnativecommunity.asyncstorage">

</manifest>

Loading

0 comments on commit 4440fb5

Please sign in to comment.