diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c9b90dfa7f..d8bb7bffddb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/android/app/build.gradle b/android/app/build.gradle index 7497179f9d7..d5f82117bb5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -8,7 +8,7 @@ android { defaultConfig { applicationId "com.flatbuffers.app" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 30 versionCode 1 versionName "1.0" @@ -18,6 +18,14 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + sourceSets { + main { + java { + srcDir '../../java' + } + } + } + ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' } @@ -105,30 +113,6 @@ 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 { @@ -136,6 +120,8 @@ dependencies { 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' } diff --git a/android/app/src/main/cpp/generated/animal_generated.h b/android/app/src/main/cpp/generated/animal_generated.h index aa23ec38175..5253f67ccad 100644 --- a/android/app/src/main/cpp/generated/animal_generated.h +++ b/android/app/src/main/cpp/generated/animal_generated.h @@ -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 { diff --git a/android/app/src/main/java/generated/com/fbs/app/Animal.kt b/android/app/src/main/java/generated/com/fbs/app/Animal.kt index 214e6155a84..f647fef678c 100644 --- a/android/app/src/main/java/generated/com/fbs/app/Animal.kt +++ b/android/app/src/main/java/generated/com/fbs/app/Animal.kt @@ -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)