There are many Android advertising platforms and different markets have different levels of acceptance for each platform. Android Developers should consider the following two issues if they want to integrate advertising:
(1) What advertisements are integrated to make money?
(2) What advertisements are integrated and will not be rejected by the market?
The final result is often a compromise.
The first problem is the judgment of the advertising platform. I have no right to comment. This article focuses on the second problem.
The solution is to package different advertisement platform versions of the application. This article will discuss related topics one by one.
1. Basics
This article is intended for Android Learning Series (6)-app modularization and engineering extension and Android Learning Series (31) -- app automation: an extension and application scenario in ant compilation Project multi-channel packaging.
So of course we need these two articles.ArticleBasic:
(1) Application of the android class library
(2). This step is optional if you want to manually update the compiled and packaged scripts because you need to automatically compile various market versions.
2. Selection of advertising platforms
Let me take three platforms as an example: wanpu, youmi, and orange.
Here I emphasize that I do not advertise. I do not recommend these three platforms, but I just use the three platforms as an example. At the same time, I also want to scold these advertising platforms, drag fees, and deduct the amount.
Why choose these three platforms?
(1 ). wanpu has a relatively high unit price, a large number of applications, and a good income. Many developers choose this platform. However, because of the user experience and points wall issues pushed before, wanpu has been banned by many markets, which is very typical.
(2 ). youmi, the promotion is good, but it is generally reflected that the income is low. banner advertisements and integral walls are separated, so the banner part can be taken out separately and published to some markets with strict requirements.
(3 ). orange, I don't know much about it for the time being. There is a credit wall, and it seems that the payment is relatively positive. Many new platforms are very active at the beginning (just pick a new platform to accompany it)
Some people say that using aggregation can use different ad platforms. I think this is totally different from the two discussed in this article. Five thousand words are omitted here.
3. integrated architecture
Before discussing the integration architecture, we must discuss the association between applications and advertisements:
(1). If there is a many-to-many relationship, an advertisement platform will certainly be embedded in many applications. An application often needs to release versions of multiple advertisement platforms.
(2 ). there is a one-to-many relationship, which is in conflict with the first one. However, the SDK of the advertising platform solves the problem of embedding in various applications, and many-to-many solutions must be considered, it will be very troublesome and has little value, so our focus is to release versions of multiple ad platforms for one application.
(3) first advertising, then application, and then advertising platform. This means that ad integration is taken into account at the beginning, but it is only a blank space, where the banner is displayed, where an application recommendation is displayed, and a blank method interface. Then, the application is developed; after the application is completed, consider how to integrate different advertising platforms, rewrite different advertising spaces based on different platforms, or display advertisements in different forms.
Under these considerations, I will draw the following integrated architecture diagram:
This architecture diagram is an example of a series of applications. Not only can each application publish multiple advertisement versions, but also a base library can encapsulate and customize multiple applications. This is a typical example.
4. Example
I have applied this idea to the world project. See https://github.com/openproject/world2.
And after verification, the effect is good.
Of course, I will skip the specific ad placeholder and overwrite here. You can also refer toCode.
5. compilation problems
For different advertising platforms, we need to make some modifications to the automatic compilation and packaging script.
(1). Issue of ant compilation for layer-3 projects: Issue of R. Java file generation and resource packaging.
To emphasize this issue, we should remind you not to make a mistake.
R. Java generation, the layer-3 project must be generated three times (build. XML ):
<Echo> generating R. java for project to Dir Gen (using aapt )... </echo> <exec executable = "aapt"> <Arg value = "package"/> <Arg value = "-M"/> <Arg value = "-J "/> <Arg value = "gen"/> <Arg value = "-M"/> <Arg value = "androidmanifest. XML "/> <Arg value ="-s "/> <Arg value =" res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2.waps/Res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2/Res "/> <Arg value ="-I "/> <Arg value =" $ {Android-jar} "/> <Arg value =" -- auto-add -overlay "/> </exec> <echo> generating R. java for WAP library project to Dir Gen (using aapt )... </echo> <exec executable = "aapt"> <Arg value = "package"/> <Arg value = "-M"/> <Arg value = "-- Non-Constant -ID "/> <Arg value =" -- auto-add-overlay "/> <Arg value ="-J "/> <Arg value =" gen "/> <ARG value = "-M"/> <Arg value = ".. /baseworld2.waps/androidmanifest. XML "/> <Arg value ="-s "/> <Arg value =" res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2.waps/Res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2/Res "/> <Arg value ="-I "/> <Arg value =" $ {Android-jar} "/> </exec> <echo> generating R. java for library to Dir Gen (using aapt )... </echo> <exec executable = "aapt"> <Arg value = "package"/> <Arg value = "-M"/> <Arg value = "-- Non-Constant -ID "/> <Arg value =" -- auto-add-overlay "/> <Arg value ="-J "/> <Arg value =" gen "/> <ARG value = "-M"/> <Arg value = ".. /baseworld2/androidmanifest. XML "/> <Arg value ="-s "/> <Arg value =" res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2.waps/Res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2/Res "/> <Arg value ="-I "/> <Arg value =" $ {Android-jar} "/> </exec>
This is also true for resource packaging. Pay special attention to the order of resource folders:
<Echo> packaging Resource (include res, assets, androidmanifest. XML, etc .) to res.zip... </echo> <exec executable = "aapt"> <Arg value = "package"/> <Arg value = "-F"/> <Arg value = "-M "/> <Arg value = "androidmanifest. XML "/> <Arg value ="-s "/> <Arg value =" res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2.waps/Res "/> <Arg value ="-s "/> <Arg value = ".. /baseworld2/Res "/> <Arg value ="-a "/> <Arg value =" assets "/> <Arg value ="-I "/> <Arg value = "$ {Android-jar}"/> <Arg value = "-F"/> <Arg value = "bin/res.zip"/> <Arg value = "-- auto-add -overlay "/> </exec>
(2). Multi-Channel packaging and compilation script (build. Sh)
#! /Bin/bash # Get the file parent dirbasedir =$ (CD "$ (dirname" $0 ")"; PWD) # Get project name by Dir nameproject =$ (echo $ basedir | awk-F "/" '{print $ NF}') Project =$ {project /\. * //} # enter the right parent dircd $ basedir # markets = "WAPs Google official appchina gfan QQ nduo feiliu 3G 360 running Baidu Sohu 163 Samsung coolmart meizu Moto liantong iandroid imobile Xiaomi nearme "markets =" mumayi EO Dev "for market in $ marketsdo echo packaging project.v2.20.#market.apk... sed-I "s/\ (Android: value = \)\"\(. * \) \ "\ (Android: Name = \" umeng_channel \ "\)/\ 1 \" $ market \ "\ 3/g" androidmanifest. XML sed-I "s/\ (Android: value = \)\"\(. * \) \ "\ (Android: Name = \" youmi_channel \ "\)/\ 1 \" $ market \ "\ 3/g" androidmanifest. XML sed-I "s/\ (Android: value = \)\"\(. * \) \ "\ (Android: Name = \" waps_pid \ "\)/\ 1 \" $ market \ "\ 3/g" androidmanifest. XML ant-DAPK-name = $ project-DAPK-version = V2.1-DAPK-market = $ marketdone
These two scripts are executed under app. WAPs. For general convenience, they can be placed somewhere, and then a soft link can be created using the ln command.
6. Summary
This article can be said to be fried leftovers, new bottles of old wine, so many places are a word, if you think thinking a little jump, haha, please read the relevant articles above.
This article uses previous knowledge to solve the problem of packaging multiple advertisement platform versions for applications. I have shared some notes and hope to help you.