Skip to content

Commit

Permalink
fix: add okhttp-urlconnection to prevent crashes when using cookies, …
Browse files Browse the repository at this point in the history
…minor Android native module tweaks (#75)
  • Loading branch information
zamotany committed Aug 28, 2021
1 parent 7454156 commit c796d73
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/TesterApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(path: ':callstackrepack')

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new ChunkManagerPackage());
return packages;
}

Expand Down
3 changes: 0 additions & 3 deletions packages/TesterApp/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
rootProject.name = 'TesterApp'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
//
include ':callstackrepack'
project(':callstackrepack').projectDir = new File(rootProject.projectDir, '../../../android')
6 changes: 5 additions & 1 deletion packages/TesterApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
"name": "TesterApp",
"version": "0.0.1",
"private": true,
"workspaces": {
"nohoist": ["react-native", "react-native/**"]
},
"scripts": {
"prepare": "exit 0",
"test": "exit 0",
"lint": "exit 0",
"tsc": "exit 0",
"build": "exit 0",
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native webpack-start",
"build": "react-native webpack-bundle --entry-file index.js --bundle-output ./dist/index.bundle --dev=false",
"bundle": "react-native webpack-bundle --entry-file index.js --bundle-output ./dist/index.bundle --dev=false",
"webpack": "PLATFORM=ios webpack -c webpack.config.js"
},
"dependencies": {
Expand Down
9 changes: 5 additions & 4 deletions packages/repack/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['WebpackToolkit_kotlinVersion']
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RePack_kotlinVersion']

repositories {
google()
Expand All @@ -18,11 +18,11 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['WebpackToolkit_' + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RePack_' + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['WebpackToolkit_' + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RePack_' + name]).toInteger()
}

android {
Expand Down Expand Up @@ -126,6 +126,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.0"
}
8 changes: 4 additions & 4 deletions packages/repack/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WebpackToolkit_kotlinVersion=1.3.50
WebpackToolkit_compileSdkVersion=29
WebpackToolkit_buildToolsVersion=29.0.2
WebpackToolkit_targetSdkVersion=29
RePack_kotlinVersion=1.4.10
RePack_compileSdkVersion=29
RePack_buildToolsVersion=29.0.2
RePack_targetSdkVersion=29
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ class RemoteChunkLoader(private val reactContext: ReactContext) {
}, { code, message -> promise.reject(code, message) })
}

fun invalidate(chunkId: String) {
val file = File(reactContext.filesDir, getChunkFilePath(chunkId))
fun invalidate(chunkId: String?) {
if (chunkId != null) {
val file = File(reactContext.filesDir, getChunkFilePath(chunkId))

if(file.exists()) {
file.delete()
if (file.exists()) {
file.delete()
}
}
}

Expand Down

0 comments on commit c796d73

Please sign in to comment.