From 242ce275566122a451da2ff8ac9fb9ad82a1759e Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Fri, 16 Aug 2019 12:06:30 +0100 Subject: [PATCH] Fix the android beta build bump types too magical change to fix the build (until everything is on androidx) fun with xml remove when all deps on android x correct string upgrade deps? set vars for new libs Android Manifest stuff Upgrade more things. update dep? version darts FIX LOCKILE try overriding restore supply --- projects/Mallard/Makefile | 2 +- projects/Mallard/android/app/.project | 23 +++++ .../guardian/editions/MainApplication.class | Bin 3308 -> 2680 bytes projects/Mallard/android/app/build.gradle | 8 +- .../Mallard/android/app/proguard-rules.pro | 6 ++ .../android/app/src/main/AndroidManifest.xml | 7 +- .../guardian/editions/MainApplication.java | 81 +++++++++--------- projects/Mallard/android/build.gradle | 15 +++- projects/Mallard/fastlane/Fastfile | 1 - projects/Mallard/ios/Podfile | 1 - projects/Mallard/package.json | 8 +- .../scripts/get-settings-pages-html.js | 38 +++++--- projects/Mallard/yarn.lock | 16 ++-- 13 files changed, 130 insertions(+), 76 deletions(-) create mode 100644 projects/Mallard/android/app/.project diff --git a/projects/Mallard/Makefile b/projects/Mallard/Makefile index 0070be22ea..dd5373a2e3 100644 --- a/projects/Mallard/Makefile +++ b/projects/Mallard/Makefile @@ -18,5 +18,5 @@ beta-android: mkdir -p android/app/src/main/assets yarn jetify yarn bundle-android - rm -rf android/app/src/main/res/drawable-* + cd android && ./gradlew clean && cd .. fastlane android beta diff --git a/projects/Mallard/android/app/.project b/projects/Mallard/android/app/.project new file mode 100644 index 0000000000..ac485d7c3e --- /dev/null +++ b/projects/Mallard/android/app/.project @@ -0,0 +1,23 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/projects/Mallard/android/app/bin/src/main/java/com/guardian/editions/MainApplication.class b/projects/Mallard/android/app/bin/src/main/java/com/guardian/editions/MainApplication.class index 73a6fb1ce45d56bee6d5892ed799e71bd33fbccb..90fe8b7b81bb781abbc3dba4fbda7daa621aa990 100644 GIT binary patch delta 99 zcmaDO`9oyFdL}lui5oAnC+4LTm41Oaj5B1qDT^#l_)? zMR}Qd>BW;9S>z{Iu=;TaBqnDkrlX| C$s+Fn delta 378 zcmew%@MnU$B{G#Nd(h8Uw{00R1xuupQ zXE^2LC&4su7MJHH<`rk==iwCDy_t{s7$ciwQBh)LF<8|~7Ht;a#LT?OKn90*YGrZ; zh_jAGjW@{8**CE`J2fRNGqoHf!UYrwPfdbxd4l|+G7B8RensS~~ PC;#H~Wwe^?!DRpdH}Hi) diff --git a/projects/Mallard/android/app/build.gradle b/projects/Mallard/android/app/build.gradle index 63342296a3..93d0f96e5a 100644 --- a/projects/Mallard/android/app/build.gradle +++ b/projects/Mallard/android/app/build.gradle @@ -193,10 +193,10 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules // These should be auto linked. TODO: TEST THIS - implementation "com.google.android.gms:play-services-base:16.1.0" - implementation 'com.google.android.gms:play-services-gcm:16.1.0' - implementation "com.google.firebase:firebase-core:16.0.9" - implementation "com.google.firebase:firebase-messaging:18.0.0" + implementation "com.google.android.gms:play-services-base:17.1.0" + implementation 'com.google.android.gms:play-services-gcm:17.0.0' + implementation "com.google.firebase:firebase-core:17.0.1" + implementation "com.google.firebase:firebase-messaging:19.0.1" if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") diff --git a/projects/Mallard/android/app/proguard-rules.pro b/projects/Mallard/android/app/proguard-rules.pro index 11b025724a..c4b83df76d 100644 --- a/projects/Mallard/android/app/proguard-rules.pro +++ b/projects/Mallard/android/app/proguard-rules.pro @@ -8,3 +8,9 @@ # http://developer.android.com/guide/developing/tools/proguard.html # 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 *; +#} diff --git a/projects/Mallard/android/app/src/main/AndroidManifest.xml b/projects/Mallard/android/app/src/main/AndroidManifest.xml index d3320094ad..1b82d87a9a 100644 --- a/projects/Mallard/android/app/src/main/AndroidManifest.xml +++ b/projects/Mallard/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.guardian.editions" xmlns:tools="http://schemas.android.com/tools"> @@ -21,7 +21,10 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + tools:replace="android:appComponentFactory" + android:appComponentFactory="androidx.core.app.CoreComponentFactory" + > diff --git a/projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.java b/projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.java index 7ddf020d2e..8f0571b27e 100644 --- a/projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.java +++ b/projects/Mallard/android/app/src/main/java/com/guardian/editions/MainApplication.java @@ -2,7 +2,10 @@ import android.app.Application; +import android.util.Log; import com.facebook.react.PackageList; +import com.facebook.hermes.reactexecutor.HermesExecutorFactory; +import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; @@ -14,49 +17,49 @@ 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() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + + // packages.add(new MainReactPackage()); + // packages.add(new RNDeviceInfo()); + // packages.add(new NetInfoPackage()); + // packages.add(new RNSentryPackage()); + // packages.add(new ReactNativePushNotificationPackage()); + // packages.add(new ReactNativeConfigPackage()); + // packages.add(new KeychainPackage()); + // packages.add(new RNCMaskedViewPackage()); + // packages.add(new RNCWebViewPackage()); + // packages.add(new RNZipArchivePackage()); + // packages.add(new SvgPackage()); + // packages.add(new AsyncStoragePackage()); + // packages.add(new RNFetchBlobPackage()); + // packages.add(new RNScreensPackage()); + // packages.add(new RNGestureHandlerPackage()); + return packages; + } + + @Override + protected String getJSMainModuleName() { + return "index"; + } + }; @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - - // packages.add(new MainReactPackage()); - // packages.add(new RNDeviceInfo()); - // packages.add(new NetInfoPackage()); - // packages.add(new RNSentryPackage()); - // packages.add(new ReactNativePushNotificationPackage()); - // packages.add(new ReactNativeConfigPackage()); - // packages.add(new KeychainPackage()); - // packages.add(new RNCMaskedViewPackage()); - // packages.add(new RNCWebViewPackage()); - // packages.add(new RNZipArchivePackage()); - // packages.add(new SvgPackage()); - // packages.add(new AsyncStoragePackage()); - // packages.add(new RNFetchBlobPackage()); - // packages.add(new RNScreensPackage()); - // packages.add(new RNGestureHandlerPackage()); - return packages; + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; } @Override - protected String getJSMainModuleName() { - return "index"; + public void onCreate() { + super.onCreate(); + SoLoader.init(this, /* native exopackage */ false); } - }; - - @Override - public ReactNativeHost getReactNativeHost() { - return mReactNativeHost; - } - - @Override - public void onCreate() { - super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); - } } diff --git a/projects/Mallard/android/build.gradle b/projects/Mallard/android/build.gradle index 606c23854a..da2a075f65 100644 --- a/projects/Mallard/android/build.gradle +++ b/projects/Mallard/android/build.gradle @@ -6,9 +6,11 @@ buildscript { minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 - supportLibVersion = "28.0.0" - googlePlayServicesVersion = "16.+" - firebaseVersion = "17.6.0" + supportLibVersion = '1.0.2' // Use '28.0.0' or don't specify for old libraries, '1.0.2' or similar for AndroidX + mediaCompatVersion = '1.0.1' // Do not specify if using old libraries, specify '1.0.1' or similar for androidx.media:media dependency + supportV4Version = '1.0.0' // Do not specify if using old libraries, specify '1.0.0' or similar for androidx.legacy:legacy-support-v4 dependency + googlePlayServicesVersion = "17.1.0" + firebaseVersion = "19.0.1" } repositories { google() @@ -38,9 +40,14 @@ allprojects { } } + configurations.all { resolutionStrategy { force 'com.google.android.gms:play-services-gcm:16.1.0' + dependencySubstitution { + substitute module("com.android.support:appcompat-v7:1.0.2") because "this is a simulcrum module because react-native-notifications isn't actively developed any more" with module("androidx.appcompat:appcompat:1.0.2") + } } + } } -} + diff --git a/projects/Mallard/fastlane/Fastfile b/projects/Mallard/fastlane/Fastfile index cc84f9d3c3..d7647ffa3c 100644 --- a/projects/Mallard/fastlane/Fastfile +++ b/projects/Mallard/fastlane/Fastfile @@ -48,7 +48,6 @@ end platform :android do desc "Push a new internal testing build to Google Play" lane :beta do - gradle(task: 'clean', project_dir: 'android/') gradle(task: 'assemble', build_type: 'Release', project_dir: 'android/', diff --git a/projects/Mallard/ios/Podfile b/projects/Mallard/ios/Podfile index 9c7ca693bf..97cee0eb7f 100644 --- a/projects/Mallard/ios/Podfile +++ b/projects/Mallard/ios/Podfile @@ -16,7 +16,6 @@ target 'Mallard' do pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket' - pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' diff --git a/projects/Mallard/package.json b/projects/Mallard/package.json index d9a5d4332d..3de23aa102 100644 --- a/projects/Mallard/package.json +++ b/projects/Mallard/package.json @@ -16,7 +16,7 @@ "run-ipad": "yarn pre-run && react-native run-ios --simulator=\"iPad Air 2\"", "validate": "cd ../.. && yarn validate-mallard", "fix": "cd ../.. && yarn fix-mallard", - "bundle-android": "yarn pre-bundle && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res", + "bundle-android": "yarn pre-bundle && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/generated/res/react/release", "bundle-ios": "yarn pre-bundle && yarn install-pods && react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest=ios", "rn-link": "react-native link", "bundle-html": "node ./scripts/bundle-html.js", @@ -60,7 +60,7 @@ "react-native-iap": "^3.3.9", "react-native-in-app-utils": "^6.0.1", "react-native-keychain": "^3.1.3", - "react-native-push-notification": "^3.1.8", + "react-native-push-notification": "^3.1.7", "react-native-screens": "^1.0.0-alpha.23", "react-native-sentry": "^0.43.2", "react-native-status-bar-height": "^2.4.0", @@ -81,7 +81,7 @@ "@types/jest": "^24.0.17", "@types/node": "^12.7.2", "@types/react": "^16.9.1", - "@types/react-native": "^0.60.4", + "@types/react-native": "^0.60.5", "@types/react-native-push-notification": "^3.0.6", "@types/react-navigation": "^3.0.8", "@types/react-test-renderer": "^16.9.0", @@ -97,7 +97,7 @@ }, "resolutions": { "@types/react": "16.9.1", - "@types/react-native": "0.60.4" + "@types/react-native": "0.60.5" }, "jest": { "preset": "react-native" diff --git a/projects/Mallard/scripts/get-settings-pages-html.js b/projects/Mallard/scripts/get-settings-pages-html.js index d61978b563..4299e03c79 100644 --- a/projects/Mallard/scripts/get-settings-pages-html.js +++ b/projects/Mallard/scripts/get-settings-pages-html.js @@ -1,4 +1,4 @@ -const fetch = require('node-fetch'); +const fetch = require('node-fetch') const path = require('path') const fs = require('fs') @@ -9,26 +9,40 @@ const capiApiKey = process.env.CAPI_API_KEY * Value represents the name of the file the html of the article is written to. */ const settingsPagePathsToFetch = { - 'mobile/ipad-edition-faqs': 'faq', - 'help/privacy-policy' : 'privacy-policy', - 'help/terms-of-service': 'terms-of-service', + 'mobile/ipad-edition-faqs': 'faq', + 'help/privacy-policy': 'privacy-policy', + 'help/terms-of-service': 'terms-of-service', } const fetchHtmlForPath = async path => { - const res = await fetch(`https://content.guardianapis.com/${path}?show-fields=body&api-key=${capiApiKey}&format=json`) + const res = await fetch( + `https://content.guardianapis.com/${path}?show-fields=body&api-key=${capiApiKey}&format=json`, + ) const json = await res.json() return json.response.content.fields.body } if (!capiApiKey) { - console.log(`You haven't set the environment var: CAPI_API_KEY. The script will not run.`) + console.log( + `You haven't set the environment var: CAPI_API_KEY. The script will not run.`, + ) } else { - Object.keys(settingsPagePathsToFetch).map( async urlPath => { + Object.keys(settingsPagePathsToFetch).map(async urlPath => { try { const bodyHtml = await fetchHtmlForPath(urlPath) - fs.writeFileSync(path.join(process.cwd(), `/src/constants/settings/${settingsPagePathsToFetch[urlPath]}.json`), `${ JSON.stringify({'bodyHtml' : bodyHtml}) }`) - } catch(error) { - console.log("FAILED (contents of settings file will not have been modified): " + error) + fs.writeFileSync( + path.join( + process.cwd(), + `/src/constants/settings/${settingsPagePathsToFetch[urlPath]}.json`, + ), + `${JSON.stringify({ bodyHtml: bodyHtml })}`, + ) + } catch (error) { + console.log( + 'FAILED (contents of settings file will not have been modified): ' + + error, + ) process.exit(1) - }}) -} \ No newline at end of file + } + }) +} diff --git a/projects/Mallard/yarn.lock b/projects/Mallard/yarn.lock index 505b3d981f..204acee775 100644 --- a/projects/Mallard/yarn.lock +++ b/projects/Mallard/yarn.lock @@ -1085,10 +1085,10 @@ resolved "https://registry.yarnpkg.com/@types/react-native-push-notification/-/react-native-push-notification-3.0.6.tgz#07fe6b0b45dc1128949d2925d8e9ae4ed35c4790" integrity sha512-OmgCbcG1d16NKD08Y+ZPrbdiR4z7wig6cj65VSy8Vx4AHq2sTTkKc4V8e65nNDeFj4oscGFiJCljyRYZ5xb7bA== -"@types/react-native@*", "@types/react-native@0.60.4", "@types/react-native@^0.60.4": - version "0.60.4" - resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.60.4.tgz#fbb04caca44c4b25a13273dbaa825dd6360376d2" - integrity sha512-XeS8nhATawGFf18bgpH2sAduZJg88/kRULJ6xCDlCsco8u7rR3hLz2JxgBMyIYfov4XTt7Ue4Nqi+86dVJvhAg== +"@types/react-native@*", "@types/react-native@0.60.5", "@types/react-native@^0.60.5": + version "0.60.5" + resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.60.5.tgz#24371cdc724f95381f9b309b08204827dd8de251" + integrity sha512-OWk8r2HzDKkas5WGFfin7CFuSgDsXvO9tDUqNemitbrlXhQ41Zk1R3lv8Vsc843X8NIb/+BO0IQKw72Pd84UNA== dependencies: "@types/prop-types" "*" "@types/react" "*" @@ -5482,10 +5482,10 @@ react-native-keychain@^3.1.3: resolved "https://registry.yarnpkg.com/react-native-keychain/-/react-native-keychain-3.1.3.tgz#fce176e7b95243cecda1896a7e6bdfe0335d778a" integrity sha512-eWUbjYJge4icX8FhWJk/OPlyGxPnW9bZDysBX3WwOG37iurdH692HKnM2Ih+S+0te65RytImvUrcVnHVBbumYg== -react-native-push-notification@^3.1.8: - version "3.1.8" - resolved "https://registry.yarnpkg.com/react-native-push-notification/-/react-native-push-notification-3.1.8.tgz#18c0dbac93333676afb0f7c6c33f031b0ffb9774" - integrity sha512-cnehwFi8sNXE0Vth2PEybrhfyQNSe0Pe49AxqNHiwhIiGP0NQiOC1IVXoUaGpF+hpw+HdWoC7m2ZIRmckB03hw== +react-native-push-notification@^3.1.7: + version "3.1.9" + resolved "https://registry.yarnpkg.com/react-native-push-notification/-/react-native-push-notification-3.1.9.tgz#760ee06e743fef74fc9fcb672dac40794fdc4c47" + integrity sha512-YpEg9AYBjNgJtHRgHKR0xPB7kk3Gj0uSjUxd0feOIvd7wrfR+zeiBM4NZonGmjlAG6thaE37dfAG5qcsONFM7w== dependencies: "@react-native-community/push-notification-ios" "^1.0.1"