Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ar/expo 52 #1276

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
.expo/
dist/
expo-env.d.ts
npm-debug.*
*.jks
*.p8
Expand Down
49 changes: 20 additions & 29 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ if (System.getenv('EX_UPDATES_NATIVE_DEBUG') == "1") {
}
}

project.ext.react = [
enableHermes: true, // Enable Hermes
enableHermesDebugging: true, // Enable source maps generation
]

/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
Expand All @@ -27,18 +22,18 @@ react {
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
debuggableVariants = expoDebuggableVariants

// Use Expo CLI to bundle the app, this ensures the Metro config
// works correctly with Expo projects.
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"

/* 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")

cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand All @@ -49,9 +44,7 @@ react {
/* 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)
Expand All @@ -71,12 +64,10 @@ react {
// 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"]
}
// hermesFlags = ["-O", "-output-source-map"]

// Override `hermesEnabled` by `expo.jsEngine`
ext {
hermesEnabled = (findProperty('hermesEnabled') ?: true)
/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand All @@ -100,6 +91,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
android {
ndkVersion rootProject.ext.ndkVersion

buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

Expand Down Expand Up @@ -159,9 +151,10 @@ android {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
// minifyEnabled false
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
Comment on lines +154 to +157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Build configuration properties partially defined

The review requires adjustment as only some of the referenced properties are defined in gradle.properties:

  • android.enablePngCrunchInReleaseBuilds is defined and set to true
  • expo.useLegacyPackaging is defined and set to false
  • android.enableShrinkResourcesInReleaseBuilds is missing from the configuration

The build will use the default fallback values for undefined properties as implemented in build.gradle, but it's recommended to explicitly define all configurable properties for better maintainability.

🔗 Analysis chain

LGTM: Enhanced build configuration flexibility

The changes improve resource management by making shrinkResources, crunchPngs, and useLegacyPackaging configurable through properties. This allows for better control over the build process.

Also applies to: 171-171

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of these properties in gradle.properties
# Expected: These properties should be defined in gradle.properties

echo "Checking for build properties in gradle.properties..."
rg -l "android\.enableShrinkResourcesInReleaseBuilds|android\.enablePngCrunchInReleaseBuilds|expo\.useLegacyPackaging" "android/gradle.properties"

Length of output: 289


Script:

#!/bin/bash
# Let's check the actual content of gradle.properties to verify if these properties are properly defined
echo "Checking the content of gradle.properties..."
cat android/gradle.properties

# Also check if there are any other files that might be overriding these properties
echo -e "\nChecking for other potential property definitions..."
rg "android\.enable(ShrinkResourcesInReleaseBuilds|PngCrunchInReleaseBuilds)" --type properties

Length of output: 2562

}
}

Expand All @@ -172,12 +165,16 @@ android {
lint {
abortOnError false
}

packagingOptions {
jniLibs {
pickFirsts += ['**/libcrypto.so']
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
}
}

androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}

// Apply static values from `gradle.properties` to the `android.packagingOptions`
Expand All @@ -204,11 +201,11 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation 'com.google.firebase:firebase-messaging-ktx:23.0.3'
implementation 'com.google.firebase:firebase-messaging-ktx:24.0.1'
implementation 'com.beust:klaxon:5.5'
implementation 'androidx.security:security-crypto:1.1.0-alpha05'
implementation "org.xmtp:android"
implementation 'org.web3j:crypto'
implementation "org.xmtp:android:0.16.2"
implementation 'org.web3j:crypto:4.9.4'
implementation 'com.google.crypto.tink:tink-android:1.7.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.tencent:mmkv:1.3.1'
Expand Down Expand Up @@ -238,7 +235,6 @@ dependencies {
}

implementation("androidx.core:core-splashscreen:1.0.0")
// implementation 'org.web3j:core:4.8.8-android'

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand All @@ -247,11 +243,6 @@ dependencies {
}
}


apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");

applyNativeModulesAppBuildGradle(project)

apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: "io.sentry.android.gradle"
apply plugin: 'com.google.gms.google-services'
Expand Down
10 changes: 1 addition & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@
<data android:scheme="oneinch" android:host="*"/>
</intent>
</queries>
<application android:name=".MainApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher_preview" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_preview_round" android:theme="@style/BootTheme" android:usesCleartextTraffic="true">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/49a65fae-3895-4487-8e8a-5bd8bee3a401"/>
<!-- <meta-data android:name="expo.modules.notifications.default_notification_icon" android:resource="@drawable/ic_default_expo_notifications"/>-->
<!-- <meta-data android:name="expo.modules.notifications.default_notification_color" android:resource="@color/notification_icon_color"/>-->
<meta-data android:name="io.sentry.dsn" android:value="https://fb7c7cbf876644b68a05db08623c8369@o4504757119680512.ingest.sentry.io/4504757120729088"/>
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="false"/>
<meta-data android:name="io.sentry.attach-screenshot" android:value="false"/>
Expand Down Expand Up @@ -95,11 +93,5 @@
<data android:host="dev.converse.xyz" android:pathPrefix="/desktopconnect" android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
<!-- <service android:name=".PushNotificationsService" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service> -->
</application>
</manifest>
6 changes: 4 additions & 2 deletions android/app/src/main/java/com/converse/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

import expo.modules.ApplicationLifecycleDispatcher
Expand All @@ -21,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
val packages = PackageList(this).packages
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return PackageList(this).packages
return packages
}

override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
Expand All @@ -40,7 +42,7 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = 34
targetSdkVersion = 34
kotlinVersion = "1.9.23"
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = "1.9.24"
Comment on lines +5 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update Kotlin Gradle plugin to match the Kotlin version

The kotlinVersion has been updated to "1.9.24", but the Kotlin Gradle plugin in the dependencies section is still using version "1.8.0". For consistency and to avoid potential compatibility issues, update the plugin version to match the Kotlin version.

Apply this diff to update the plugin version:

 dependencies {
     classpath('com.android.tools.build:gradle:8.5.0')
     classpath('com.facebook.react:react-native-gradle-plugin')
-    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0'
+    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
     classpath("io.sentry:sentry-android-gradle-plugin:3.11.1")
     classpath 'com.google.gms:google-services:4.4.0'
 }

Committable suggestion skipped: line range outside the PR's diff.


ndkVersion = "26.1.10909125"
}
Expand Down
9 changes: 7 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ org.gradle.jvmargs=-Xmx4608m -XX:MaxMetaspaceSize=2g
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.enablePngCrunchInReleaseBuilds=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand All @@ -47,3 +46,9 @@ expo.webp.enabled=true
# Enable animated webp support (~3.4 MB increase)
# Disabled by default because iOS doesn't support animated webp
expo.webp.animated=false

# Enable network inspector
EX_DEV_CLIENT_NETWORK_INSPECTOR=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Disable network inspector in production builds

EX_DEV_CLIENT_NETWORK_INSPECTOR=true enables the network inspector, which is useful during development but can pose security risks and performance overhead in production. Ensure this is disabled or conditionally set based on the build type.

Apply a conditional check to set this property only in debug builds.


# Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -82,7 +84,8 @@ done

# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
Expand Down
2 changes: 2 additions & 0 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
27 changes: 24 additions & 3 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using .execute() due to potential security risks

Using .execute() to run external commands can pose security risks and may lead to inconsistent behavior across different environments. Consider using Gradle's built-in mechanisms or properties to resolve plugin paths without executing external processes.


plugins { id("com.facebook.react.settings") }

extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
ex.autolinkLibrariesFromCommand()
} else {
def command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'android'
].toList()
ex.autolinkLibrariesFromCommand(command)
}
}

rootProject.name = 'Converse'

dependencyResolutionManagement {
Expand All @@ -11,8 +35,5 @@ dependencyResolutionManagement {
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())
Loading
Loading