Browse Source

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

Arnaud Vergnet 3 years ago
parent
commit
baf1a9f563

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

77
 
77
 
78
 project.ext.react = [
78
 project.ext.react = [
79
     entryFile: "index.js",
79
     entryFile: "index.js",
80
-    enableHermes: true,
80
+    enableHermes: true,  // clean and rebuild if changing
81
 ]
81
 ]
82
 
82
 
83
 apply from: "../../node_modules/react-native/react.gradle"
83
 apply from: "../../node_modules/react-native/react.gradle"
184
         pickFirst "lib/x86_64/libc++_shared.so"
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
     // applicationVariants are e.g. debug, release
195
     // applicationVariants are e.g. debug, release
188
     applicationVariants.all { variant ->
196
     applicationVariants.all { variant ->
189
         variant.outputs.each { output ->
197
         variant.outputs.each { output ->
206
     implementation "com.facebook.react:react-native:+"  // From node_modules
214
     implementation "com.facebook.react:react-native:+"  // From node_modules
207
 
215
 
208
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
216
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
217
+
209
     debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
218
     debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
210
       exclude group:'com.facebook.fbjni'
219
       exclude group:'com.facebook.fbjni'
211
     }
220
     }
221
+
212
     debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
222
     debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
213
         exclude group:'com.facebook.flipper'
223
         exclude group:'com.facebook.flipper'
214
     }
224
     }
225
+
215
     debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
226
     debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
216
         exclude group:'com.facebook.flipper'
227
         exclude group:'com.facebook.flipper'
217
     }
228
     }

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

1
+<?xml version="1.0" encoding="utf-8"?>
1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
     xmlns:tools="http://schemas.android.com/tools">
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
  * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
4
  * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
  * directory of this source tree.
5
  * directory of this source tree.
6
  */
6
  */
7
-package com.rndiffapp;
7
+package fr.amicaleinsat.application;
8
+
8
 import android.content.Context;
9
 import android.content.Context;
9
 import com.facebook.flipper.android.AndroidFlipperClient;
10
 import com.facebook.flipper.android.AndroidFlipperClient;
10
 import com.facebook.flipper.android.utils.FlipperUtils;
11
 import com.facebook.flipper.android.utils.FlipperUtils;
64
       }
65
       }
65
     }
66
     }
66
   }
67
   }
67
-}
68
+}

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

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
     <uses-permission android:name="android.permission.INTERNET"/>
3
     <uses-permission android:name="android.permission.INTERNET"/>
3
     <uses-permission android:name="android.permission.CAMERA"/>
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
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
7
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
7
     <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
8
     <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
8
-
9
     <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
9
     <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
10
+
10
     <application
11
     <application
11
             android:name=".MainApplication"
12
             android:name=".MainApplication"
12
             android:label="@string/app_name"
13
             android:label="@string/app_name"
16
             android:theme="@style/AppTheme"
17
             android:theme="@style/AppTheme"
17
             android:usesCleartextTraffic="true"
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
         <!-- Change the resource name to your App's accent color - or any other color you want -->
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
         <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
30
         <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
30
             <intent-filter>
31
             <intent-filter>
31
-                <action android:name="android.intent.action.BOOT_COMPLETED" />
32
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
32
             </intent-filter>
33
             </intent-filter>
33
         </receiver>
34
         </receiver>
34
 
35
 
35
         <service
36
         <service
36
                 android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
37
                 android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
37
-                android:exported="false" >
38
+                android:exported="false">
38
             <intent-filter>
39
             <intent-filter>
39
-                <action android:name="com.google.firebase.MESSAGING_EVENT" />
40
+                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
40
             </intent-filter>
41
             </intent-filter>
41
         </service>
42
         </service>
42
 
43
 
43
-<!--        END NOTIFICATIONS-->
44
+        <!--        END NOTIFICATIONS-->
44
 
45
 
45
 
46
 
46
         <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
47
         <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
47
         <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
48
         <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
48
         <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false"/>
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
             <intent-filter>
57
             <intent-filter>
54
                 <action android:name="android.intent.action.MAIN"/>
58
                 <action android:name="android.intent.action.MAIN"/>
55
                 <category android:name="android.intent.category.LAUNCHER"/>
59
                 <category android:name="android.intent.category.LAUNCHER"/>
63
         </activity>
67
         </activity>
64
         <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
68
         <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
65
     </application>
69
     </application>
66
-</manifest>
70
+</manifest>

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

33
      */
33
      */
34
     @Override
34
     @Override
35
     protected String getMainComponentName() {
35
     protected String getMainComponentName() {
36
-        return "main";
36
+        return "Campus";
37
     }
37
     }
38
 
38
 
39
     @Override
39
     @Override

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

18
 
18
 
19
 public class MainApplication extends Application implements ReactApplication {
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
   @Override
43
   @Override
40
   public ReactNativeHost getReactNativeHost() {
44
   public ReactNativeHost getReactNativeHost() {

+ 6
- 1
index.js View File

1
+/**
2
+ * @format
3
+ */
4
+
1
 import {AppRegistry} from 'react-native';
5
 import {AppRegistry} from 'react-native';
2
 import App from './App';
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
     "@react-navigation/stack": "^5.2.17",
29
     "@react-navigation/stack": "^5.2.17",
30
     "i18n-js": "^3.3.0",
30
     "i18n-js": "^3.3.0",
31
     "react": "16.11.0",
31
     "react": "16.11.0",
32
-    "react-dom": "16.9.0",
33
     "react-native": "0.62.2",
32
     "react-native": "0.62.2",
34
     "react-native-animatable": "^1.3.3",
33
     "react-native-animatable": "^1.3.3",
35
     "react-native-app-intro-slider": "^4.0.0",
34
     "react-native-app-intro-slider": "^4.0.0",
58
     "react-navigation-header-buttons": "^4.0.2"
57
     "react-navigation-header-buttons": "^4.0.2"
59
   },
58
   },
60
   "devDependencies": {
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
     "babel-jest": "^25.5.1",
63
     "babel-jest": "^25.5.1",
65
     "eslint": "^6.5.1",
64
     "eslint": "^6.5.1",
66
     "flow-bin": "^0.123.0",
65
     "flow-bin": "^0.123.0",
67
     "jest": "^25.5.3",
66
     "jest": "^25.5.3",
68
     "jest-extended": "^0.11.5",
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
     "react-test-renderer": "16.11.0"
69
     "react-test-renderer": "16.11.0"
71
   }
70
   }
72
 }
71
 }

Loading…
Cancel
Save