fix: Distribute Android code as source (#234)

* Build Android as source

* more reliably find `enableHermes`
This commit is contained in:
Marc Rousavy 2021-07-08 10:52:14 +02:00 committed by GitHub
parent 349b1146b0
commit b2f3c08a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 108 deletions

View File

@ -10,8 +10,6 @@ on:
- 'example/android/**'
- 'yarn.lock'
- 'example/yarn.lock'
- 'scripts/build-android-npm-package.sh'
- 'android-npm/**'
pull_request:
paths:
- '.github/workflows/build-android.yml'
@ -19,46 +17,8 @@ on:
- 'example/android/**'
- 'yarn.lock'
- 'example/yarn.lock'
- 'scripts/build-android-npm-package.sh'
- 'android-npm/**'
jobs:
build_lib:
name: Build Android Library (.aar)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore node_modules from cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install node_modules for example/
run: yarn install --frozen-lockfile
- name: Restore Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build .aar
run: scripts/build-android-npm-package.sh
build_example:
name: Build Android Example App
runs-on: ubuntu-latest

3
.gitignore vendored
View File

@ -68,6 +68,3 @@ docs/typedoc-sidebar.js
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# npm package aars
android-npm/*.aar

View File

@ -1,18 +0,0 @@
import groovy.json.JsonSlurper;
configurations.maybeCreate("default")
def inputFile = new File(projectDir, '../../react-native/package.json')
def json = new JsonSlurper().parseText(inputFile.text)
def reactNativeVersion = json.version as String
def (major, minor, patch) = reactNativeVersion.tokenize('.')
def engine = "jsc"
rootProject.getSubprojects().forEach({project ->
if (project.plugins.hasPlugin("com.android.application")) {
if(project.ext.react.enableHermes) {
engine = "hermes"
}
}
})
artifacts.add("default", file("react-native-vision-camera-${engine}.aar"))

View File

@ -1,3 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mrousavy.camera">
</manifest>

View File

@ -1,8 +0,0 @@
package com.mrousavy.camera;
import com.facebook.react.ReactPackage;
import com.mrousavy.camera.CameraPackage;
public class CameraPackage implements ReactPackage {
// dummy package
}

View File

@ -4,12 +4,12 @@ import java.nio.file.Paths
def reactNative = new File("$projectDir/../node_modules/react-native")
def FOR_HERMES = "";
if(findProject(':app')) {
FOR_HERMES = project(':app').ext.react.enableHermes;
} else {
FOR_HERMES = System.getenv("FOR_HERMES") == "True";
def FOR_HERMES = System.getenv("FOR_HERMES") == "True";
rootProject.getSubprojects().forEach({project ->
if (project.plugins.hasPlugin("com.android.application")) {
FOR_HERMES = project.ext.react.enableHermes;
}
})
/**
* Finds the path of the installed npm package with the given name using Node's

View File

@ -31,7 +31,7 @@
"typescript": "tsc --noEmit",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"lint-ci": "yarn lint -f ./node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js",
"build": "bob build && scripts/build-android-npm-package.sh",
"build": "bob build",
"release": "release-it",
"pods": "cd example && yarn pods",
"bootstrap": "yarn && cd example && yarn && yarn pods",
@ -42,9 +42,7 @@
"clean-ios": "scripts/clean-ios.sh",
"clean-android": "scripts/clean-android.sh",
"clean-js": "scripts/clean-js.sh",
"docs": "cd docs && yarn build",
"prepack": "rm -rf android-tmp && mv android android-tmp && mv android-npm android",
"postpack": "rm -rf android-npm && mv android android-npm && mv android-tmp android"
"docs": "cd docs && yarn build"
},
"keywords": [
"react-native",

View File

@ -1,26 +0,0 @@
#!/bin/bash
set -e
ROOT=$(pwd)
rm -rf android-npm/*.aar
for for_hermes in "True" "False"
do
engine="jsc"
if [ "$for_hermes" == "True" ]; then
engine="hermes"
fi
echo "Building VisionCamera for JS Engine ${engine}..."
cd android
./gradlew clean
FOR_HERMES=${for_hermes} ./gradlew assembleDebug
cd ..
cp android/build/outputs/aar/*.aar "android-npm/react-native-vision-camera-${engine}.aar"
echo "Built react-native-vision-camera-${engine}.aar!"
done
echo "Finished building VisionCamera packages!"