DEV Community

Saqib Iqbal
Saqib Iqbal

Posted on AI-assisted

6 Android lessons from shipping my first Expo app to Google Play

Lensora app screens: the document library with category filters and the Save Document screenI'm a solo developer from Lahore, and a few weeks ago I shipped my first Android app: Lensora, an offline document scanner and PDF toolkit built with Expo SDK 54 / React Native 0.81. It scans pages with Google's ML Kit document scanner, runs OCR on the device, stores everything in SQLite and does PDF work with pdf-lib.

The app worked perfectly in development. Then real phones, release builds and Play Console recommendations happened. Here are six things that bit me, with the fixes. Hopefully they save you a weekend.

1. "Enable R8 optimization" broke my database, only in release

Play Console showed me two friendly recommendations: "Optimization isn't enabled" and "Optimized resource shrinking isn't enabled". The Expo template minifies with proguard-android.txt, which turns R8's optimization passes off. So I wrote a small config plugin:

// plugins/withR8Optimization.js (do not copy without reading the rest)
const { withAppBuildGradle, withGradleProperties } = require('@expo/config-plugins');

function withOptimizedProguardFile(config) {
  return withAppBuildGradle(config, (cfg) => {
    cfg.modResults.contents = cfg.modResults.contents.replace(
      'getDefaultProguardFile("proguard-android.txt")',
      'getDefaultProguardFile("proguard-android-optimize.txt")'
    );
    return cfg;
  });
}

function withOptimizedResourceShrinking(config) {
  return withGradleProperties(config, (cfg) => {
    cfg.modResults.push({ type: 'property', key: 'android.r8.optimizedResourceShrinking', value: 'true' });
    return cfg;
  });
}
Enter fullscreen mode Exit fullscreen mode

The dev build was fine. The release build on the internal testing track could not open SQLite at all: the credit balance showed "-", importing a PDF failed, earned credits weren't saved. Every screen failed quietly in its own way.

I removed the plugin and went back to plain minify + resource shrinking (enableMinifyInReleaseBuilds and enableShrinkResourcesInReleaseBuilds in expo-build-properties), and everything worked again.

Lessons:

  • A Play Console recommendation is not a requirement. Test it like any other risky change.
  • Always test the release build (internal testing track) before promoting. Dev builds don't run R8.
  • Make storage failures loud. I now show the real error instead of failing silently screen by screen:
initDatabase()
  .then(() => initCredits())
  .catch((e) => {
    const reason = e instanceof Error ? e.message : String(e);
    Alert.alert(
      'Storage problem',
      `Lensora could not open its storage on this phone. Please restart the app.\n\n${reason.slice(0, 300)}`
    );
  });
Enter fullscreen mode Exit fullscreen mode

2. market:// links opened the wrong app store

My "Rate this app" button used the classic:

Linking.openURL('market://details?id=com.example.app');
Enter fullscreen mode Exit fullscreen mode

On my Infinix test phone it did not open Google Play. Infinix, Tecno and itel phones (Transsion brands, very common in Pakistan, Africa and South Asia) ship their own store, Palm Store, which also claims market:// links.

React Native's openURL just fires an ACTION_VIEW intent; whoever claims the scheme wins. The fix is to use the https URL, which Google Play owns as a verified app link:

const PLAY_URL = 'https://play.google.com/store/apps/details?id=com.example.app';

export async function openPlayListing() {
  try {
    await Linking.openURL(PLAY_URL); // Play app if installed, browser otherwise
  } catch {
    Alert.alert('Could not open Google Play', 'Please search for the app in the Play Store.');
  }
}
Enter fullscreen mode Exit fullscreen mode

Bonus: you can add &utm_source=…&utm_campaign=… and see those visits in Play Console's acquisition reports.

3. The keyboard covered my text inputs (edge-to-edge)

New Android builds run edge-to-edge, so the window no longer resizes when the keyboard opens. A KeyboardAvoidingView without a behavior does nothing, and inputs near the bottom vanished under the keyboard.

What worked for me was measuring the keyboard and padding the scroll content myself:

export function useKeyboardHeight(): number {
  const [height, setHeight] = useState(0);
  useEffect(() => {
    const show = Keyboard.addListener('keyboardDidShow', (e) => setHeight(e.endCoordinates.height));
    const hide = Keyboard.addListener('keyboardDidHide', () => setHeight(0));
    return () => {
      show.remove();
      hide.remove();
    };
  }, []);
  return height;
}

// In the screen:
const keyboardHeight = useKeyboardHeight();
<ScrollView contentContainerStyle={{ paddingBottom: keyboardHeight + 24 }}>…</ScrollView>
Enter fullscreen mode Exit fullscreen mode

I pair it with a small helper that scrolls the focused field into view once keyboardDidShow fires, and I hide the sticky footer buttons while the keyboard is up.

4. autoFocus in a Modal didn't open the keyboard

I had a "Name your PDF" dialog with a pre-selected default name. autoFocus focused the field visually, but on Android the keyboard didn't open until the user tapped, which also cleared the selection. Annoying.

Focusing after the Modal has finished showing fixes it:

export function focusAfterShow(ref: React.RefObject<TextInput | null>) {
  setTimeout(() => ref.current?.focus(), 120);
}

<Modal visible={visible} transparent onShow={() => focusAfterShow(inputRef)}>
  <TextInput ref={inputRef} defaultValue={suggestedName} selectTextOnFocus />
</Modal>
Enter fullscreen mode Exit fullscreen mode

5. Native modules called through reflection need keep rules

To show previews of imported PDFs I added react-native-pdf-thumbnail, which uses Android's built-in PdfRenderer. Two things to remember with any native module:

  • It needs a new dev build (not just a JS reload). "Module doesn't seem to be linked" usually just means that.
  • If R8 is on, keep the module's classes, or release builds may break in ways the dev build never shows:
["expo-build-properties", {
  "android": {
    "enableMinifyInReleaseBuilds": true,
    "enableShrinkResourcesInReleaseBuilds": true,
    "extraProguardRules": "-keep class org.songsterq.pdfthumbnail.** { *; }"
  }
}]
Enter fullscreen mode Exit fullscreen mode

I keep one keep rule per native library that the JS bridge looks up by name (PDF viewer, Wi-Fi, document scanner, ML Kit, ads, WebView).

6. A ".docx" that wasn't a Word file

Users can open Word files and convert them to PDF (I use mammoth for this). A tester reported "Cannot open file" on a .docx. The file turned out to be plain text with a .docx extension, which some apps and websites produce.

A real .docx is a zip archive, so I now check the bytes before parsing: a PK header at the start and an end-of-central-directory record near the end.

function looksLikeZip(bytes: Uint8Array): boolean {
  if (bytes.length < 22 || bytes[0] !== 0x50 || bytes[1] !== 0x4b) return false; // "PK"
  const stop = Math.max(0, bytes.length - 65_557);
  for (let i = bytes.length - 22; i >= stop; i--) {
    if (bytes[i] === 0x50 && bytes[i + 1] === 0x4b && bytes[i + 2] === 0x05 && bytes[i + 3] === 0x06) return true;
  }
  return false;
}
Enter fullscreen mode Exit fullscreen mode

If it isn't a zip, I fall back: show text files as text, explain old .doc (OLE) files clearly, and only then say "not a valid Word document". Trusting the extension is how you end up with a confusing error for a perfectly readable file.

What I'd tell myself before launch

  • Ship to the internal testing track first, every time. It's the only place you see release-only behaviour, and builds are usually available to testers within minutes.
  • Test on a cheap phone from a popular local brand, not just a Pixel. Mine found the Palm Store issue.
  • Make failures visible. A silent catch {} in storage code cost me a confused afternoon.

The app from this post is Lensora: a free, offline PDF and receipt scanner for Android with no account and no uploads. If you want to see these fixes in a real app, it's on Google Play, and the site is lensorapdf.app.

Happy to answer questions in the comments about Expo builds, ML Kit document scanning or AdMob rewarded ads.

Top comments (0)