Skip to content

Commit 9a68de6

Browse files
committed
Upgrade Android
1 parent 892899e commit 9a68de6

File tree

13 files changed

+129
-291
lines changed

13 files changed

+129
-291
lines changed

android/app/build.gradle

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34

4-
import com.android.build.OutputFile
55

66
// project.ext.react = [
77
// entryFile: "index.js",
@@ -17,8 +17,8 @@ react {
1717
root = file("../../")
1818
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
1919
reactNativeDir = file("../../node_modules/react-native")
20-
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
21-
// codegenDir = file("../node_modules/react-native-codegen")
20+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
21+
// codegenDir = file("../node_modules/@react-native/codegen")
2222
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
2323
// cliFile = file("../node_modules/react-native/cli.js")
2424
/* Variants */
@@ -53,12 +53,6 @@ react {
5353
// hermesFlags = ["-O", "-output-source-map"]
5454
}
5555

56-
/* Set this to true to create four separate APKs instead of one,
57-
* one for each native architecture. This is useful if you don't
58-
* use App Bundles (https://developer.android.com/guide/app-bundle/)
59-
* and want to have separate APKs to upload to the Play Store.
60-
*/
61-
def enableSeparateBuildPerCPUArchitecture = false
6256
/**
6357
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
6458
*/
@@ -75,18 +69,13 @@ def enableProguardInReleaseBuilds = false
7569
* this variant is about 6MiB larger per architecture than default.
7670
*/
7771
def jscFlavor = 'org.webkit:android-jsc:+'
78-
/* Private function to get the list of Native Architectures you want to build.
79-
* This reads the value from reactNativeArchitectures in your gradle.properties
80-
* file and works together with the --active-arch-only flag of react-native run-android.
81-
*/
82-
def reactNativeArchitectures() {
83-
def value = project.getProperties().get("reactNativeArchitectures")
84-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
85-
}
8672

8773
android {
88-
compileSdkVersion rootProject.ext.compileSdkVersion
8974
ndkVersion rootProject.ext.ndkVersion
75+
76+
buildToolsVersion rootProject.ext.buildToolsVersion
77+
compileSdk rootProject.ext.compileSdkVersion
78+
9079
namespace "com.rnuilib"
9180

9281
defaultConfig {
@@ -98,14 +87,6 @@ android {
9887
multiDexEnabled true
9988
}
10089

101-
splits {
102-
abi {
103-
reset()
104-
enable enableSeparateBuildPerCPUArchitecture
105-
universalApk false // If true, also generate a universal APK
106-
include (*reactNativeArchitectures())
107-
}
108-
}
10990
signingConfigs {
11091
debug {
11192
storeFile file('debug.keystore')
@@ -126,34 +107,12 @@ android {
126107
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
127108
}
128109
}
129-
130-
// applicationVariants are e.g. debug, release
131-
applicationVariants.all { variant ->
132-
variant.outputs.each { output ->
133-
// For each separate APK per architecture, set a unique version code as described here:
134-
// https://developer.android.com/studio/build/configure-apk-splits.html
135-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
136-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
137-
def abi = output.getFilter(OutputFile.ABI)
138-
if (abi != null) { // null for the universal-debug, universal-release variants
139-
output.versionCodeOverride =
140-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
141-
}
142-
143-
}
144-
}
145110
}
146111

147112
dependencies {
148113
// The version of react-native is set by the React Native Gradle Plugin
149114
implementation("com.facebook.react:react-android")
150-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
151-
152-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
153-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
154-
exclude group:'com.squareup.okhttp3', module:'okhttp'
155-
}
156-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
115+
implementation("com.facebook.react:flipper-integration")
157116

158117
implementation project(':react-native-navigation')
159118
implementation project(':react-native-ui-lib')

android/app/src/debug/AndroidManifest.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6-
7-
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning">
8-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
9-
</application>
10-
</manifest>
5+
<application
6+
android:usesCleartextTraffic="true"
7+
tools:targetApi="28"
8+
tools:ignore="GoogleAppIndexingWarning"/>
9+
</manifest>

android/app/src/debug/java/com/rnuilib/ReactNativeFlipper.java

Lines changed: 0 additions & 75 deletions
This file was deleted.

android/app/src/main/java/com/rnuilib/MainActivity.java

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.rnuilib;
2+
3+
import com.facebook.react.ReactActivity
4+
import com.facebook.react.ReactActivityDelegate
5+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6+
import com.facebook.react.defaults.DefaultReactActivityDelegate
7+
import com.reactnativenavigation.NavigationActivity
8+
9+
class MainActivity : NavigationActivity() {
10+
11+
/**
12+
* Returns the name of the main component registered from JavaScript. This is used to schedule
13+
* rendering of the component.
14+
*/
15+
// override fun getMainComponentName(): String = "rnuilib"
16+
17+
/**
18+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
19+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
20+
*/
21+
// override fun createReactActivityDelegate(): ReactActivityDelegate =
22+
// DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
23+
}

android/app/src/main/java/com/rnuilib/MainApplication.java

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.rnuilib;
2+
3+
import android.app.Application
4+
import com.facebook.react.PackageList
5+
import com.facebook.react.ReactApplication
6+
import com.facebook.react.ReactHost
7+
import com.facebook.react.ReactNativeHost
8+
import com.facebook.react.ReactPackage
9+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11+
import com.facebook.react.defaults.DefaultReactNativeHost
12+
import com.facebook.react.flipper.ReactNativeFlipper
13+
import com.facebook.soloader.SoLoader
14+
import com.reactnativenavigation.NavigationApplication
15+
import com.wix.reactnativeuilib.UiLibPackageList;
16+
17+
class MainApplication : NavigationApplication() {
18+
19+
override val reactNativeHost: ReactNativeHost =
20+
object : DefaultReactNativeHost(this) {
21+
override fun getPackages(): List<ReactPackage> =
22+
PackageList(this).packages.apply {
23+
// Packages that cannot be autolinked yet can be added manually here, for example:
24+
// add(UiLibPackageList(MainApplication.this).getPackageList())
25+
addAll(UiLibPackageList(this@MainApplication).getPackageList())
26+
// add(MyReactNativePackage())
27+
}
28+
29+
override fun getJSMainModuleName(): String = "demo"
30+
31+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
32+
33+
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
34+
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
35+
}
36+
37+
override val reactHost: ReactHost
38+
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
39+
40+
override fun onCreate() {
41+
super.onCreate()
42+
SoLoader.init(this, false)
43+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
44+
// If you opted-in for the New Architecture, we load the native entry point for this app.
45+
load()
46+
}
47+
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
48+
}
49+
}

android/app/src/release/java/com/rnuilib/ReactNativeFlipper.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)