From baf1a9f5637dd7a8aa2bc8aac8eb05a472b98880 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Sun, 31 May 2020 15:39:07 +0200 Subject: [PATCH] Updated android config file to better match vanilla react native project and fixed release apk crash on some devices --- android/app/build.gradle | 13 +++++- android/app/src/debug/AndroidManifest.xml | 1 + .../application/ReactNativeFlipper.java | 5 +- android/app/src/main/AndroidManifest.xml | 46 ++++++++++--------- .../application/MainActivity.java | 2 +- .../application/MainApplication.java | 34 ++++++++------ index.js | 7 ++- package.json | 9 ++-- 8 files changed, 71 insertions(+), 46 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 63edf36..0771330 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -77,7 +77,7 @@ import com.android.build.OutputFile project.ext.react = [ entryFile: "index.js", - enableHermes: true, + enableHermes: true, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" @@ -184,6 +184,14 @@ android { pickFirst "lib/x86_64/libc++_shared.so" } + // Force so_loader version to fix crash on apk release + configurations.all { + resolutionStrategy { + force "com.facebook.soloader:soloader:0.8.2" + } + } + + // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> @@ -206,12 +214,15 @@ dependencies { implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } + debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 99e38fc..fa26aa5 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,3 +1,4 @@ + diff --git a/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java b/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java index 07e08af..0a10cd2 100644 --- a/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java +++ b/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java @@ -4,7 +4,8 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.rndiffapp; +package fr.amicaleinsat.application; + import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; import com.facebook.flipper.android.utils.FlipperUtils; @@ -64,4 +65,4 @@ public class ReactNativeFlipper { } } } -} \ No newline at end of file +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cff76b4..10d8792 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,12 +1,13 @@ - + - - + + - + - - - + + + - + - + - + + android:exported="false"> - + - + - + @@ -63,4 +67,4 @@ - \ No newline at end of file + diff --git a/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java b/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java index 59aaa6f..a2024b1 100644 --- a/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java +++ b/android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java @@ -33,7 +33,7 @@ public class MainActivity extends ReactActivity { */ @Override protected String getMainComponentName() { - return "main"; + return "Campus"; } @Override diff --git a/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java b/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java index 86c81f6..239eff4 100644 --- a/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java +++ b/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java @@ -18,23 +18,27 @@ import javax.annotation.Nullable; public class MainApplication extends Application implements ReactApplication { - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } + private final ReactNativeHost mReactNativeHost = + new ReactNativeHost(this) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } - @Override - protected List getPackages() { - List packages = new PackageList(this).getPackages(); - return packages; - } + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + // Packages that cannot be autolinked yet can be added manually here, for example: + // packages.add(new MyReactNativePackage()); + return packages; + } - @Override - protected String getJSMainModuleName() { - return "index"; - } - }; + @Override + protected String getJSMainModuleName() { + return "index"; + } + }; @Override public ReactNativeHost getReactNativeHost() { diff --git a/index.js b/index.js index afe81fd..a850d03 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,9 @@ +/** + * @format + */ + import {AppRegistry} from 'react-native'; import App from './App'; +import {name as appName} from './app.json'; -AppRegistry.registerComponent('main', () => App); \ No newline at end of file +AppRegistry.registerComponent(appName, () => App); diff --git a/package.json b/package.json index e6940c7..63c31ba 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@react-navigation/stack": "^5.2.17", "i18n-js": "^3.3.0", "react": "16.11.0", - "react-dom": "16.9.0", "react-native": "0.62.2", "react-native-animatable": "^1.3.3", "react-native-app-intro-slider": "^4.0.0", @@ -58,15 +57,15 @@ "react-navigation-header-buttons": "^4.0.2" }, "devDependencies": { - "@babel/core": "^7.9.6", - "@babel/runtime": "^7.9.6", - "@react-native-community/eslint-config": "^1.1.0", + "@babel/core": "^7.6.2", + "@babel/runtime": "^7.6.2", + "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^25.5.1", "eslint": "^6.5.1", "flow-bin": "^0.123.0", "jest": "^25.5.3", "jest-extended": "^0.11.5", - "metro-react-native-babel-preset": "^0.59.0", + "metro-react-native-babel-preset": "^0.58.0", "react-test-renderer": "16.11.0" } }