Browse Source

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

Arnaud Vergnet 4 years ago
parent
commit
baf1a9f563

+ 12
- 1
android/app/build.gradle View File

@@ -77,7 +77,7 @@ import com.android.build.OutputFile
77 77
 
78 78
 project.ext.react = [
79 79
     entryFile: "index.js",
80
-    enableHermes: true,
80
+    enableHermes: true,  // clean and rebuild if changing
81 81
 ]
82 82
 
83 83
 apply from: "../../node_modules/react-native/react.gradle"
@@ -184,6 +184,14 @@ android {
184 184
         pickFirst "lib/x86_64/libc++_shared.so"
185 185
     }
186 186
 
187
+    // Force so_loader version to fix crash on apk release
188
+    configurations.all {
189
+        resolutionStrategy {
190
+            force "com.facebook.soloader:soloader:0.8.2"
191
+        }
192
+    }
193
+
194
+
187 195
     // applicationVariants are e.g. debug, release
188 196
     applicationVariants.all { variant ->
189 197
         variant.outputs.each { output ->
@@ -206,12 +214,15 @@ dependencies {
206 214
     implementation "com.facebook.react:react-native:+"  // From node_modules
207 215
 
208 216
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
217
+
209 218
     debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
210 219
       exclude group:'com.facebook.fbjni'
211 220
     }
221
+
212 222
     debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
213 223
         exclude group:'com.facebook.flipper'
214 224
     }
225
+
215 226
     debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
216 227
         exclude group:'com.facebook.flipper'
217 228
     }

+ 1
- 0
android/app/src/debug/AndroidManifest.xml View File

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

+ 3
- 2
android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java View File

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

+ 25
- 21
android/app/src/main/AndroidManifest.xml View File

@@ -1,12 +1,13 @@
1
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.amicaleinsat.application">
1
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+          package="fr.amicaleinsat.application">
2 3
     <uses-permission android:name="android.permission.INTERNET"/>
3 4
     <uses-permission android:name="android.permission.CAMERA"/>
4
-    <uses-permission android:name="android.permission.WAKE_LOCK" />
5
-    <uses-permission android:name="android.permission.VIBRATE" />
5
+    <uses-permission android:name="android.permission.WAKE_LOCK"/>
6
+    <uses-permission android:name="android.permission.VIBRATE"/>
6 7
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
7 8
     <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
8
-
9 9
     <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
10
+
10 11
     <application
11 12
             android:name=".MainApplication"
12 13
             android:label="@string/app_name"
@@ -16,40 +17,43 @@
16 17
             android:theme="@style/AppTheme"
17 18
             android:usesCleartextTraffic="true"
18 19
     >
19
-<!--        NOTIFICATIONS -->
20
-        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
21
-                    android:value="reminders"/>
22
-        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
23
-                    android:value="reminders"/>
20
+        <!--        NOTIFICATIONS -->
21
+        <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
22
+                   android:value="reminders"/>
23
+        <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
24
+                   android:value="reminders"/>
24 25
         <!-- Change the resource name to your App's accent color - or any other color you want -->
25
-        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
26
-                    android:resource="@color/colorPrimary"/> <!-- or @android:color/{name} to use a standard color -->
26
+        <meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
27
+                   android:resource="@color/colorPrimary"/> <!-- or @android:color/{name} to use a standard color -->
27 28
 
28
-        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
29
+        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"/>
29 30
         <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
30 31
             <intent-filter>
31
-                <action android:name="android.intent.action.BOOT_COMPLETED" />
32
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
32 33
             </intent-filter>
33 34
         </receiver>
34 35
 
35 36
         <service
36 37
                 android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
37
-                android:exported="false" >
38
+                android:exported="false">
38 39
             <intent-filter>
39
-                <action android:name="com.google.firebase.MESSAGING_EVENT" />
40
+                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
40 41
             </intent-filter>
41 42
         </service>
42 43
 
43
-<!--        END NOTIFICATIONS-->
44
+        <!--        END NOTIFICATIONS-->
44 45
 
45 46
 
46 47
         <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
47 48
         <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
48 49
         <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false"/>
49
-        <activity android:name=".MainActivity" android:label="@string/app_name"
50
-                  android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
51
-                  android:launchMode="singleTask" android:windowSoftInputMode="adjustResize"
52
-                  android:screenOrientation="portrait">
50
+        <activity
51
+                android:name=".MainActivity"
52
+                android:label="@string/app_name"
53
+                android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
54
+                android:launchMode="singleTask"
55
+                android:windowSoftInputMode="adjustResize"
56
+                android:screenOrientation="portrait">
53 57
             <intent-filter>
54 58
                 <action android:name="android.intent.action.MAIN"/>
55 59
                 <category android:name="android.intent.category.LAUNCHER"/>
@@ -63,4 +67,4 @@
63 67
         </activity>
64 68
         <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
65 69
     </application>
66
-</manifest>
70
+</manifest>

+ 1
- 1
android/app/src/main/java/fr/amicaleinsat/application/MainActivity.java View File

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

+ 19
- 15
android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java View File

@@ -18,23 +18,27 @@ import javax.annotation.Nullable;
18 18
 
19 19
 public class MainApplication extends Application implements ReactApplication {
20 20
 
21
-  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
22
-    @Override
23
-    public boolean getUseDeveloperSupport() {
24
-      return BuildConfig.DEBUG;
25
-    }
21
+  private final ReactNativeHost mReactNativeHost =
22
+      new ReactNativeHost(this) {
23
+        @Override
24
+        public boolean getUseDeveloperSupport() {
25
+          return BuildConfig.DEBUG;
26
+        }
26 27
 
27
-    @Override
28
-    protected List<ReactPackage> getPackages() {
29
-      List<ReactPackage> packages = new PackageList(this).getPackages();
30
-      return packages;
31
-    }
28
+        @Override
29
+        protected List<ReactPackage> getPackages() {
30
+          @SuppressWarnings("UnnecessaryLocalVariable")
31
+          List<ReactPackage> packages = new PackageList(this).getPackages();
32
+          // Packages that cannot be autolinked yet can be added manually here, for example:
33
+          // packages.add(new MyReactNativePackage());
34
+          return packages;
35
+        }
32 36
 
33
-    @Override
34
-    protected String getJSMainModuleName() {
35
-      return "index";
36
-    }
37
-  };
37
+        @Override
38
+        protected String getJSMainModuleName() {
39
+          return "index";
40
+        }
41
+      };
38 42
 
39 43
   @Override
40 44
   public ReactNativeHost getReactNativeHost() {

+ 6
- 1
index.js View File

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

+ 4
- 5
package.json View File

@@ -29,7 +29,6 @@
29 29
     "@react-navigation/stack": "^5.2.17",
30 30
     "i18n-js": "^3.3.0",
31 31
     "react": "16.11.0",
32
-    "react-dom": "16.9.0",
33 32
     "react-native": "0.62.2",
34 33
     "react-native-animatable": "^1.3.3",
35 34
     "react-native-app-intro-slider": "^4.0.0",
@@ -58,15 +57,15 @@
58 57
     "react-navigation-header-buttons": "^4.0.2"
59 58
   },
60 59
   "devDependencies": {
61
-    "@babel/core": "^7.9.6",
62
-    "@babel/runtime": "^7.9.6",
63
-    "@react-native-community/eslint-config": "^1.1.0",
60
+    "@babel/core": "^7.6.2",
61
+    "@babel/runtime": "^7.6.2",
62
+    "@react-native-community/eslint-config": "^0.0.5",
64 63
     "babel-jest": "^25.5.1",
65 64
     "eslint": "^6.5.1",
66 65
     "flow-bin": "^0.123.0",
67 66
     "jest": "^25.5.3",
68 67
     "jest-extended": "^0.11.5",
69
-    "metro-react-native-babel-preset": "^0.59.0",
68
+    "metro-react-native-babel-preset": "^0.58.0",
70 69
     "react-test-renderer": "16.11.0"
71 70
   }
72 71
 }

Loading…
Cancel
Save