Updated android config file to better match vanilla react native project and fixed release apk crash on some devices

This commit is contained in:
Arnaud Vergnet 2020-05-31 15:39:07 +02:00
parent cc82a8c8a9
commit baf1a9f563
8 changed files with 71 additions and 46 deletions

View file

@ -77,7 +77,7 @@ import com.android.build.OutputFile
project.ext.react = [ project.ext.react = [
entryFile: "index.js", entryFile: "index.js",
enableHermes: true, enableHermes: true, // clean and rebuild if changing
] ]
apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native/react.gradle"
@ -184,6 +184,14 @@ android {
pickFirst "lib/x86_64/libc++_shared.so" 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 are e.g. debug, release
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
@ -206,12 +214,15 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni' exclude group:'com.facebook.fbjni'
} }
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper' exclude group:'com.facebook.flipper'
} }
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper' exclude group:'com.facebook.flipper'
} }

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">

View file

@ -4,7 +4,8 @@
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree. * directory of this source tree.
*/ */
package com.rndiffapp; package fr.amicaleinsat.application;
import android.content.Context; import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient; import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.android.utils.FlipperUtils; import com.facebook.flipper.android.utils.FlipperUtils;
@ -64,4 +65,4 @@ public class ReactNativeFlipper {
} }
} }
} }
} }

View file

@ -1,12 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.amicaleinsat.application"> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.amicaleinsat.application">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<application <application
android:name=".MainApplication" android:name=".MainApplication"
android:label="@string/app_name" android:label="@string/app_name"
@ -16,40 +17,43 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
> >
<!-- NOTIFICATIONS --> <!-- NOTIFICATIONS -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="reminders"/> android:value="reminders"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="reminders"/> android:value="reminders"/>
<!-- Change the resource name to your App's accent color - or any other color you want --> <!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color" <meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/colorPrimary"/> <!-- or @android:color/{name} to use a standard color --> android:resource="@color/colorPrimary"/> <!-- or @android:color/{name} to use a standard color -->
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<service <service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" > android:exported="false">
<intent-filter> <intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" /> <action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter> </intent-filter>
</service> </service>
<!-- END NOTIFICATIONS--> <!-- END NOTIFICATIONS-->
<meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/> <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/> <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false"/> <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false"/>
<activity android:name=".MainActivity" android:label="@string/app_name" <activity
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:name=".MainActivity"
android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:label="@string/app_name"
android:screenOrientation="portrait"> android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
@ -63,4 +67,4 @@
</activity> </activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/> <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
</application> </application>
</manifest> </manifest>

View file

@ -33,7 +33,7 @@ public class MainActivity extends ReactActivity {
*/ */
@Override @Override
protected String getMainComponentName() { protected String getMainComponentName() {
return "main"; return "Campus";
} }
@Override @Override

View file

@ -18,23 +18,27 @@ import javax.annotation.Nullable;
public class MainApplication extends Application implements ReactApplication { public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { private final ReactNativeHost mReactNativeHost =
@Override new ReactNativeHost(this) {
public boolean getUseDeveloperSupport() { @Override
return BuildConfig.DEBUG; public boolean getUseDeveloperSupport() {
} return BuildConfig.DEBUG;
}
@Override @Override
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages(); @SuppressWarnings("UnnecessaryLocalVariable")
return packages; List<ReactPackage> 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 @Override
protected String getJSMainModuleName() { protected String getJSMainModuleName() {
return "index"; return "index";
} }
}; };
@Override @Override
public ReactNativeHost getReactNativeHost() { public ReactNativeHost getReactNativeHost() {

View file

@ -1,4 +1,9 @@
/**
* @format
*/
import {AppRegistry} from 'react-native'; import {AppRegistry} from 'react-native';
import App from './App'; import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent('main', () => App); AppRegistry.registerComponent(appName, () => App);

View file

@ -29,7 +29,6 @@
"@react-navigation/stack": "^5.2.17", "@react-navigation/stack": "^5.2.17",
"i18n-js": "^3.3.0", "i18n-js": "^3.3.0",
"react": "16.11.0", "react": "16.11.0",
"react-dom": "16.9.0",
"react-native": "0.62.2", "react-native": "0.62.2",
"react-native-animatable": "^1.3.3", "react-native-animatable": "^1.3.3",
"react-native-app-intro-slider": "^4.0.0", "react-native-app-intro-slider": "^4.0.0",
@ -58,15 +57,15 @@
"react-navigation-header-buttons": "^4.0.2" "react-navigation-header-buttons": "^4.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.9.6", "@babel/core": "^7.6.2",
"@babel/runtime": "^7.9.6", "@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^1.1.0", "@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^25.5.1", "babel-jest": "^25.5.1",
"eslint": "^6.5.1", "eslint": "^6.5.1",
"flow-bin": "^0.123.0", "flow-bin": "^0.123.0",
"jest": "^25.5.3", "jest": "^25.5.3",
"jest-extended": "^0.11.5", "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" "react-test-renderer": "16.11.0"
} }
} }