Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Remove maven dependency of flatbuffers and use source folder #7503

Merged
merged 1 commit into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 26
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