Unverified Commit f2fd84d6 authored by Hanwen Cheng's avatar Hanwen Cheng Committed by GitHub
Browse files

build: Adopt React Native 0.61 and Unlink manual-linked-libraries (#557)

* fix path

* merge master branch

* build: update polkadot dependencies and remove redundant packages

* update kusama metadata to latest

* fix tests

* update react native

* stash

* unlink libraries

* unlink libraries

* Delete RNSecureStorage.podspec

* Update README.md

* Update README.md
parent d505f05f
Pipeline #82451 failed with stages
in 3 minutes and 41 seconds
...@@ -42,7 +42,6 @@ DerivedData ...@@ -42,7 +42,6 @@ DerivedData
*.hmap *.hmap
*.ipa *.ipa
*.xcuserstate *.xcuserstate
project.xcworkspace
# Android/IntelliJ # Android/IntelliJ
# #
...@@ -53,6 +52,7 @@ local.properties ...@@ -53,6 +52,7 @@ local.properties
*.iml *.iml
gen/ gen/
*.hprof *.hprof
!debug.keystore
# node.js # node.js
# #
......
...@@ -40,6 +40,7 @@ Parity Signer was built to be used offline. The mobile device used to run the ap ...@@ -40,6 +40,7 @@ Parity Signer was built to be used offline. The mobile device used to run the ap
- `rustup` (tested on `rustup 1.16.0`) - `rustup` (tested on `rustup 1.16.0`)
- `rustc` (tested on `rustc 1.32.0 (9fda7c223 2019-01-16)`) - `rustc` (tested on `rustc 1.32.0 (9fda7c223 2019-01-16)`)
- `cargo` (tested on `cargo 1.32.0 (8610973aa 2019-01-02)`) - `cargo` (tested on `cargo 1.32.0 (8610973aa 2019-01-02)`)
- `cocoapods` (`$ sudo gem install cocoapods`)
- `android_ndk` (tested on `r19`) - `android_ndk` (tested on `r19`)
- `Android Studio` (only for Android, tested on `Version 3.3`) - `Android Studio` (only for Android, tested on `Version 3.3`)
- `Xcode` (only for iOS, tested on `Version 9.4.1 (9F2000)`) - `Xcode` (only for iOS, tested on `Version 9.4.1 (9F2000)`)
...@@ -71,7 +72,14 @@ Parity Signer was built to be used offline. The mobile device used to run the ap ...@@ -71,7 +72,14 @@ Parity Signer was built to be used offline. The mobile device used to run the ap
### Usage ### Usage
- First start React Native server with increased heap to prevent out of memory error - Install Dependencies
```
yarn
cd ios && pod install && cd ..
```
- Start React Native server with increased heap to prevent out of memory error
``` ```
yarn start yarn start
...@@ -190,3 +198,19 @@ This should open a menu on the device. In that menu go to `Dev Settings` > `Debu ...@@ -190,3 +198,19 @@ This should open a menu on the device. In that menu go to `Dev Settings` > `Debu
1. Edit `./android/local.properties` so that `ndk.dir` points to the absolute path to the NDK directory. 1. Edit `./android/local.properties` so that `ndk.dir` points to the absolute path to the NDK directory.
1. Remove old NDK build with `rm -rf ./NDK`. 1. Remove old NDK build with `rm -rf ./NDK`.
1. Build the new NDK with `./create-ndk-standalone.sh`. 1. Build the new NDK with `./create-ndk-standalone.sh`.
#### Cannot run after upgrade to latest codebase
1. `yarn clean`
2. `yarn install`
3. `cd ios && pod install && cd ..`
4. delete app on device
5. `yarn start --reset-cache`
##### build on iOS
6. in Xcode (be sure to open with `./ios/NativeSigner.xcodeworkspace` file), clean build with `shift + command + K`
7. `yarn run ios`
##### build on Android
6. clean build with `cd android && ./gradlew clean && cd ..`
7. `yarn run android`
...@@ -74,6 +74,7 @@ import com.android.build.OutputFile ...@@ -74,6 +74,7 @@ import com.android.build.OutputFile
project.ext.react = [ project.ext.react = [
entryFile: "index.js", entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
bundleInRelease: true, bundleInRelease: true,
nodeExecutableAndArgs: ["node", "--max_old_space_size=8192"] nodeExecutableAndArgs: ["node", "--max_old_space_size=8192"]
] ]
...@@ -97,6 +98,28 @@ def enableSeparateBuildPerCPUArchitecture = false ...@@ -97,6 +98,28 @@ def enableSeparateBuildPerCPUArchitecture = false
*/ */
def enableProguardInReleaseBuilds = false def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android { android {
compileSdkVersion rootProject.ext.compileSdkVersion compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion buildToolsVersion rootProject.ext.buildToolsVersion
...@@ -116,14 +139,16 @@ android { ...@@ -116,14 +139,16 @@ android {
ndk { ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64' abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
} }
packagingOptions {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
}
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
signingConfigs { signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release { release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) { if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE) storeFile file(MYAPP_RELEASE_STORE_FILE)
...@@ -134,7 +159,15 @@ android { ...@@ -134,7 +159,15 @@ android {
} }
} }
buildTypes { buildTypes {
debug {
signingConfig signingConfigs.debug
}
release { release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
} }
} }
splits { splits {
...@@ -157,8 +190,8 @@ android { ...@@ -157,8 +190,8 @@ android {
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here: // For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits // https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI) def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride = output.versionCodeOverride =
...@@ -169,16 +202,17 @@ android { ...@@ -169,16 +202,17 @@ android {
} }
dependencies { dependencies {
implementation project(':react-native-safe-area-context')
implementation project(':react-native-camera')
implementation project(':react-native-secure-storage') implementation project(':react-native-secure-storage')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-svg')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-randombytes')
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0' implementation "com.facebook.react:react-native:+"
implementation 'com.facebook.react:react-native:0.60.3'
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
if (useIntlJsc) { if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+' implementation 'org.webkit:android-jsc-intl:+'
...@@ -203,3 +237,5 @@ task copyDownloadableDepsToLibs(type: Copy) { ...@@ -203,3 +237,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile from configurations.compile
into 'libs' into 'libs'
} }
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
...@@ -9,13 +9,6 @@ ...@@ -9,13 +9,6 @@
# Add any project specific keep options here: # Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Disabling obfuscation is useful if you collect stack traces from production crashes # Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces). # (unless you are using a system that supports de-obfuscate the stack traces).
-dontobfuscate -dontobfuscate
......
...@@ -6,14 +6,9 @@ ...@@ -6,14 +6,9 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<!-- Default permissions which are added silently and not needed -->
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />
<uses-permission tools:node="remove" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission tools:node="remove" android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.autofocus" />
<application <application
android:name=".MainApplication" android:name=".MainApplication"
android:label="@string/app_name" android:label="@string/app_name"
......
...@@ -2,8 +2,6 @@ package io.parity.signer; ...@@ -2,8 +2,6 @@ package io.parity.signer;
import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import android.os.Bundle; import android.os.Bundle;
import android.view.WindowManager; import android.view.WindowManager;
...@@ -11,8 +9,8 @@ import android.view.WindowManager; ...@@ -11,8 +9,8 @@ import android.view.WindowManager;
public class MainActivity extends ReactActivity { public class MainActivity extends ReactActivity {
/** /**
* Returns the name of the main component registered from JavaScript. * Returns the name of the main component registered from JavaScript. This is used to schedule
* This is used to schedule rendering of the component. * rendering of the component.
*/ */
@Override @Override
protected String getMainComponentName() { protected String getMainComponentName() {
...@@ -31,11 +29,6 @@ public class MainActivity extends ReactActivity { ...@@ -31,11 +29,6 @@ public class MainActivity extends ReactActivity {
@Override @Override
protected ReactActivityDelegate createReactActivityDelegate() { protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) { return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
@Override @Override
protected Bundle getLaunchOptions() { protected Bundle getLaunchOptions() {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
......
...@@ -3,21 +3,13 @@ package io.parity.signer; ...@@ -3,21 +3,13 @@ package io.parity.signer;
import android.app.Application; import android.app.Application;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.th3rdwave.safeareacontext.SafeAreaContextPackage; import com.facebook.react.PackageList;
import com.reactlibrary.RNSecureStoragePackage;
import org.reactnative.camera.RNCameraPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.horcrux.svg.SvgPackage;
import com.bitgo.randombytes.RandomBytesPackage;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List; import java.util.List;
import android.content.Context;
public class MainApplication extends Application implements ReactApplication { public class MainApplication extends Application implements ReactApplication {
...@@ -29,17 +21,11 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -29,17 +21,11 @@ public class MainApplication extends Application implements ReactApplication {
@Override @Override
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( @SuppressWarnings("UnnecessaryLocalVariable")
new MainReactPackage(), List<ReactPackage> packages = new PackageList(this).getPackages();
new SafeAreaContextPackage(), // Packages that cannot be autolinked yet can be added manually here, for example:
new RNSecureStoragePackage(), packages.add(new EthkeyBridgePackage());
new RNCameraPackage(), return packages;
new SvgPackage(),
new NetInfoPackage(),
new RandomBytesPackage(),
new EthkeyBridgePackage(),
new RNGestureHandlerPackage()
);
} }
@Override @Override
...@@ -57,5 +43,31 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -57,5 +43,31 @@ public class MainApplication extends Application implements ReactApplication {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
SoLoader.init(this, /* native exopackage */ false); SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
} }
} }
...@@ -6,7 +6,6 @@ buildscript { ...@@ -6,7 +6,6 @@ buildscript {
minSdkVersion = 18 minSdkVersion = 18
compileSdkVersion = 28 compileSdkVersion = 28
targetSdkVersion = 28 targetSdkVersion = 28
supportLibVersion = "28.0.0"
kotlinVersion = '1.3.41' kotlinVersion = '1.3.41'
} }
repositories { repositories {
...@@ -14,7 +13,7 @@ buildscript { ...@@ -14,7 +13,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath('com.android.tools.build:gradle:3.5.1') classpath('com.android.tools.build:gradle:3.4.2')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
......
keystore(
name = 'debug',
store = 'debug.keystore',
properties = 'debug.keystore.properties',
visibility = [
'PUBLIC',
],
)
key.store=debug.keystore
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android
rootProject.name = 'Parity Signer' rootProject.name = 'Parity Signer'
include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
include ':react-native-secure-storage' include ':react-native-secure-storage'
project(':react-native-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secure-storage/android') project(':react-native-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secure-storage/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':@react-native-community_netinfo'
project(':@react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-randombytes'
project(':react-native-randombytes').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-randombytes/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app' include ':app'
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1020" LastUpgradeVersion = "1130"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "NO" parallelizeBuildables = "NO"
...@@ -55,6 +55,15 @@ ...@@ -55,6 +55,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "NativeSigner-tvOS.app"
BlueprintName = "NativeSigner-tvOS"
ReferencedContainer = "container:NativeSigner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
...@@ -67,17 +76,6 @@ ...@@ -67,17 +76,6 @@
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D02E47A1E0B4A5D006451C7"
BuildableName = "NativeSigner-tvOS.app"
BlueprintName = "NativeSigner-tvOS"
ReferencedContainer = "container:NativeSigner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
...@@ -99,8 +97,6 @@ ...@@ -99,8 +97,6 @@
ReferencedContainer = "container:NativeSigner.xcodeproj"> ReferencedContainer = "container:NativeSigner.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"
......