--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -61,6 +61,13 @@
 #  define _r pub._r
 #  define _w pub._w
 # elif defined __ANDROID__ /* Android */
+#  ifdef __LP64__
+#   define _gl_flags_file_t int
+#   define _gl_struct_file_off_t int64_t
+#  else
+#   define _gl_flags_file_t short
+#   define _gl_struct_file_off_t __kernel_off_t
+#  endif
   /* Up to this commit from 2015-10-12
      <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
      the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
@@ -70,8 +77,8 @@
 #  define fp_ ((struct { unsigned char *_p; \
                          int _r; \
                          int _w; \
-                         int _flags; \
-                         int _file; \
+                         _gl_flags_file_t _flags; \
+                         _gl_flags_file_t _file; \
                          struct { unsigned char *_base; size_t _size; } _bf; \
                          int _lbfsize; \
                          void *_cookie; \
@@ -86,7 +93,7 @@
                          unsigned char _nbuf[1]; \
                          struct { unsigned char *_base; size_t _size; } _lb; \
                          int _blksize; \
-                         fpos_t _offset; \
+                         _gl_struct_file_off_t _offset; \
                          /* More fields, not relevant here.  */ \
                        } *) fp)
 # else
