Skip to content

Commit

Permalink
[Android] Remove maven dependency of flatbuffers and use source folder
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovap committed Sep 1, 2022
1 parent a79d61e commit 71576fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -294,7 +294,6 @@ jobs:
run: echo "::set-output name=hashes::$(shasum -a 256 Mac.flatc.binary.zip | base64)"

build-android:
if: false
name: Build Android (on Linux)
runs-on: ubuntu-latest
steps:
Expand Down
38 changes: 12 additions & 26 deletions android/app/build.gradle
Expand Up @@ -8,7 +8,7 @@ android {

defaultConfig {
applicationId "com.flatbuffers.app"
minSdkVersion 16
minSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand All @@ -18,6 +18,14 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
java {
srcDir '../../java'
}
}
}

ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
Expand Down Expand Up @@ -105,37 +113,15 @@ android {
dependsOn(generateFbsCpp)
}
}

// flavorDimensions "stl-variant"
// productFlavors {
// gnustl {
// dimension "stl-variant"
// applicationIdSuffix ".gnustl"
// versionNameSuffix "-gnustl"
// externalNativeBuild {
// ndkBuild {
// arguments "APP_STL=gnustl_static"
// }
// }
// }
// libcpp {
// dimension "stl-variant"
// applicationIdSuffix ".libcpp"
// versionNameSuffix "-libcpp"
// externalNativeBuild {
// ndkBuild {
// arguments "APP_STL=c++_static"
// }
// }
// }
// }
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.flatbuffers:flatbuffers-java:2.0.0'

// If you using java runtime you can add its dependency as the example below
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'

}
7 changes: 7 additions & 0 deletions android/app/src/main/cpp/generated/animal_generated.h
Expand Up @@ -6,6 +6,13 @@

#include "flatbuffers/flatbuffers.h"

// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
FLATBUFFERS_VERSION_MINOR == 0 &&
FLATBUFFERS_VERSION_REVISION == 8,
"Non-compatible flatbuffers version included");

namespace com {
namespace fbs {
namespace app {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/java/generated/com/fbs/app/Animal.kt
Expand Up @@ -36,7 +36,7 @@ class Animal : Table() {
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
_bb.order(ByteOrder.LITTLE_ENDIAN)
Expand Down

0 comments on commit 71576fe

Please sign in to comment.