How to create admob app-ads.txt file flutter web app?

441

I also recently tried flutter web. I went on a "fishing expedition", and managed to solve this issue.

What i did:

  1. Place your app-ads.txt in <project>/web folder.
  2. Run flutter build web
  3. Check that app-ads.txt appeared in build/web folder.
  4. Check that in build/web/flutter_service_worker.js in RESOURCES map appeared a record with key "app-ads.txt"(ex. "app-ads.txt": "4c75380ac52243715a448e96239e0ca5",)
  5. Run firebase deploy --only hosting

After this, app-ads.txt should be available on https://your-domain.web.app/app-ads.txt, https://your-domain.firebaseapp.com/app-ads.txt and(if you added a custom domain) on https://my-custom-domain.com/app-ads.txt.

P.S. If you got redirected from /app-ads.txt to your main page, then try to clear your site cache:

  1. Press F12
  2. Open "Application" tab
  3. Choose "Storage"
  4. Press "Clear site data"

After this, app-ads.txt should be available.

Share:
441
Samiul Alim
Author by

Samiul Alim

Updated on January 01, 2023

Comments

  • Samiul Alim
    Samiul Alim over 1 year

    I have a website made with flutter web. My app which shows google admob ad. Now google admob told me to create an app-ads.txt file on my website . Flutter web is a single page website so, is it possible to create an app-ads.txt file with my flutter web app !?

    • Admin
      Admin over 2 years
      Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
  • Beginner_
    Beginner_ over 2 years
    Even if I try $ flutter build web, app-ads.txt are not appeared in build/web. I checked that app-ads.txt was in ProjectDir/web.
  • Beginner_
    Beginner_ over 2 years
    I could solve it↑. I added <meta http-equiv="refresh" content="app-ads.txt"> between <html><head></head></html> in ProjectDir/web/index.html