Flutter-How to earn money with Google AdMob? — Part 2

Burak Akten
4 min readMay 28, 2023

Hello Flutter lovers 💜 😄 💜

In Previous part, I mentioned that how to use Google AdMob in Flutter (Mobile) applications. I implemented for Banner Ad, Interstitial Ad and Rewarded Ad. Before or after you release your application, If you want to see some ads in your app when you install from store, you need to do an important thing. That is setting up app-ads.txt file for your app.

In this blog, I will mention that what is app-ads.txt file and how we can add this file.

Before reading this blog, I recommend you to read previous part.

What is app-ads.txt file and why we need to add?

First of all, app-ads.txt and Authorized Sellers for Apps represents same thing. It is an extension to the Authorized Digital Sellers standard. If you have this file for your app. It provide compatibility to support ads that is shown in your mobile apps. If you create and publish your file, you can have more control over allowed to sell ads on your app and also prevent from irrelevant and unreliable ads.

The app-ads.txt files are publicly available and crawlable by exchanges, supply-side platforms (SSP), and other buyers and third-party vendors.

Also If you want to see ads from your app you need to create this file and publish.

How we add App-ads.txt?

Actually there are various ways to do that but I prefer using Firebase Hosting. So I will tell about hosting your file with Firebase.

First of all, you need to link your app to Firebase to use Firebase properties for your app.

Firebase initialization

If I tried to explain shortly, these are the basic steps to link Firebase;

  1. Open Firebase console from the link.
  2. Create an project.
  3. After creating project, you will see empty firebase application.
  4. Now click the add app button and select Flutter app.
  5. You need to install firebase cli and login firebase from command panel of your computer.

Okay! Now go to your project directory and open terminal then run this command to initialize the firebase for you project.

firebase init

During the initialization, you need to activate hosting by these steps:

  1. Select to set up Hosting.
  2. Select firebase project to link it. (Use an existing project from listed projects.)
  3. Set a directory to use as your public root directory. You can only press enter to use default one.
  4. Select N for the next question. (Since the website you’re going to create is not a single-page app)
  5. Now everything done. You now see two files and one directory that is created. (public directory and firebase.json, .firebaserc files.)

Creating app-ads.txt file

Now we need to create the necessary file and fill its content.

  1. Create a file that named app-ads.txt.
  2. Put this file in public directory.
  3. Learn your publisher ID from AdMob console > Settings
  4. Copy and past the below code into your file
google.com, pub-00000000000000, DIRECT, f08c47fec0942fa0

5. Replace pub-00000000000000 part with your publisher ID.

Now everything is set. We need to publish that file. Run below code from your terminal.

firebase deploy --only hosting

When deploying is completed, go to the following URL to make sure app-ads.txt is published. PROJECT_ID is your id of firebase project. If your project called my_perfect_project in Firebase PROJECT_ID is my_perfect_project.

https://PROJECT_ID.web.app/app-ads.txt

Set link for your app

You create your necessary file and publish and you have a link for this file. Now you need to update your developer website from the store. Change the link to the below link on store setting:

https://PROJECT_ID.web.app

You done everything perfect. Now you wait at least 24 hours for AdMob to crawl and verify your app-ads.txt file. After verified, you will see a result like below from AdMob console:

Conclusion

In this article, I wanted to show you how to create/set App-ads.txt file your your app to getting paid from Google AdMob. I hope I show everything clearly.

Do not forget nothing is imposible to have or to do. They are not confusing that you think.

Do not hesitate to get in touch with me about any Flutter things☺️

I hope this article useful for you. Thank you for your time. If you liked this article please leave some 👏 and share it with friends. 🤩

Wait for another topic from me Flutter lovers 💜 😄 💜

Happy coding times 🥳🤩

Get in touch with me and see my mobile applications on this link.

Burak Akten, Flutter Developer at Profe Information Systems👈

--

--