Skip to content

Commit

Permalink
Merge pull request #320 from guardian/aw-fix-android
Browse files Browse the repository at this point in the history
Fix android build somewhat
  • Loading branch information
AWare authored Aug 19, 2019
2 parents 358ca0a + 242ce27 commit e0337f0
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 76 deletions.
2 changes: 1 addition & 1 deletion projects/Mallard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions projects/Mallard/android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
Binary file not shown.
8 changes: 4 additions & 4 deletions projects/Mallard/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions projects/Mallard/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 *;
#}
7 changes: 5 additions & 2 deletions projects/Mallard/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.guardian.editions">
package="com.guardian.editions" xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand All @@ -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"
>

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> 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<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> 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);
}
}
15 changes: 11 additions & 4 deletions projects/Mallard/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
}
}
}
}
}

1 change: 0 additions & 1 deletion projects/Mallard/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down
1 change: 0 additions & 1 deletion projects/Mallard/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions projects/Mallard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
Expand Down
38 changes: 26 additions & 12 deletions projects/Mallard/scripts/get-settings-pages-html.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fetch = require('node-fetch');
const fetch = require('node-fetch')
const path = require('path')
const fs = require('fs')

Expand All @@ -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)
}})
}
}
})
}
16 changes: 8 additions & 8 deletions projects/Mallard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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" "*"
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit e0337f0

Please sign in to comment.