Skip to content

Commit

Permalink
sc-122692:resolve build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissiewasabi committed Aug 28, 2024
1 parent e714697 commit 70c8b4e
Show file tree
Hide file tree
Showing 8 changed files with 14,936 additions and 20,999 deletions.
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RNMovableInk_kotlinVersion=1.8.0
RNMovableInk_minSdkVersion=24
RNMovableInk_targetSdkVersion=33
RNMovableInk_compileSdkVersion=33
RNMovableInk_ndkversion=23.1.7779620
kotlinVersion=1.8.0
minSdkVersion=24
targetSdkVersion=33
compileSdkVersion=33
ndkversion=23.1.7779620
android.useAndroidX=true
40 changes: 26 additions & 14 deletions android/src/main/java/com/rnmovableink/RNMovableInkModule.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.rnmovableink

import com.facebook.react.bridge.*
import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.movableink.inked.MIClient
import com.movableink.inked.MIClient.setMIU
import com.movableink.inked.inAppMessage.MovableInAppClient

class RNMovableInkModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {

override fun getName(): String {
return NAME
}
class RNMovableInkModule(
reactContext: ReactApplicationContext,
) : ReactContextBaseJavaModule(reactContext) {
override fun getName(): String = NAME

@ReactMethod
fun start() {
Expand All @@ -34,7 +36,10 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun resolveURL(url: String, promise: Promise) {
fun resolveURL(
url: String,
promise: Promise,
) {
MIClient.resolveUrlAsync(url) { resolved ->
promise.resolve(resolved)
}
Expand Down Expand Up @@ -71,7 +76,10 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun logEvent(name: String, properties: ReadableMap) {
fun logEvent(
name: String,
properties: ReadableMap,
) {
MIClient.logEvent(name, properties.toHashMap())
}

Expand All @@ -83,16 +91,20 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun showInAppMessage(url: String, callback: Callback) {
fun showInAppMessage(
url: String,
callback: Callback,
) {
currentActivity?.runOnUiThread {
MIClient.showInAppBrowser(
currentActivity!!,
url,
listener = object : MovableInAppClient.OnUrlLoadingListener {
listener =
object : MovableInAppClient.OnUrlLoadingListener {
override fun onButtonClicked(value: String) {
callback.invoke(value)
}
},
},
)
}
}
Expand All @@ -102,7 +114,7 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :
MIClient.validPasteboardValues(values.toStringList())
}

fun ReadableArray.toStringList(): List<String> {
private fun ReadableArray.toStringList(): List<String> {
val stringList = mutableListOf<String>()
for (i in 0 until size()) {
stringList.add(getString(i))
Expand Down
9 changes: 2 additions & 7 deletions android/src/main/java/com/rnmovableink/RNMovableInkPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager


class MovableInkPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return listOf(RNMovableInkModule(reactContext))
}
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = listOf(RNMovableInkModule(reactContext))

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return emptyList()
}
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> = emptyList()
}
244 changes: 122 additions & 122 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,48 @@ apply plugin: "com.facebook.react"
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node_modules/react-native-codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]

/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []

/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node_modules/react-native-codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]

/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []

/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
}

/**
Expand Down Expand Up @@ -85,96 +85,96 @@ def jscFlavor = 'org.webkit:android-jsc:+'
* file and works together with the --active-arch-only flag of react-native run-android.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

namespace "com.movableink.app"
defaultConfig {
applicationId "com.movableink.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

namespace "com.movableink.app"
defaultConfig {
applicationId "com.movableink.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}

splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}

splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}

// 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:
// // https://developer.android.com/studio/build/configure-apk-splits.html
// // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
// def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
// def abi = output.getFilter(OutputFile.ABI)
// if (abi != null) { // null for the universal-debug, universal-release variants
// output.versionCodeOverride =
// defaultConfig.versionCode * 1000 + versionCodes.get(abi)
// }

// }
// }
}

// 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:
// // https://developer.android.com/studio/build/configure-apk-splits.html
// // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
// def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
// def abi = output.getFilter(OutputFile.ABI)
// if (abi != null) { // null for the universal-debug, universal-release variants
// output.versionCodeOverride =
// defaultConfig.versionCode * 1000 + versionCodes.get(abi)
// }

// }
// }
}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

// debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
// debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
// exclude group:'com.squareup.okhttp3', module:'okhttp'
// }
// debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}

// constraints {
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
// because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
// }
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
// because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
// }
// }
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

// debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
// debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
// exclude group:'com.squareup.okhttp3', module:'okhttp'
// }
// debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}

// constraints {
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
// because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
// }
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
// because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
// }
// }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'MovableInkExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../../node_modules/react-native-gradle-plugin')
Loading

0 comments on commit 70c8b4e

Please sign in to comment.