Android notes: App apps release each ad platform version of the detailed _android

Source: Internet
Author: User
Tags constant

Android advertising platform is a lot of different markets for each platform to accept the degree is not the same, Android developers if you want to integrate advertising basic to consider the following two questions:
(1) The integration of what advertising, will make money?
(2) What ads to integrate, will not be rejected by the market?
The end result is often a compromise.
The first question is the advertising platform judgment question, I have no say to comment, this article mainly aims at the second question launches.
The solution is to package the application of the different advertising platform version, this article next to launch the relevant topic.

1. The basic
This article is an extension and application scenario for the Android notes: App Modularity and engineering extensions apps and Android notes: App Automation's use of the Ant-compiled project for multi-channel packaging.
So of course you need the basics of both articles:
(1). Application of Android Class library
(2). Because you want to combine the automatic compilation of each market version, update the compiled package script, of course, this step is optional if you are willing to manually.

2. Choice of advertising platform
Let me take three platforms for example: Wanpo, there are rice, oranges.
Here I emphasize that, I do not advertise, I do not want to recommend these three platforms, just to three platforms for example. At the same time, I also want to scold these advertising platform, drag money, buckle amount and so on.
Why choose these three platforms?
(1). Wanpo is a higher unit price, more applications, better income, a lot of developers choose this platform, but because of the user experience and the integration of the previous push-wall problem, is a lot of market ban, very typical.
(2). Have rice, propaganda to do well, but generally reflects low income, banner advertising and integration wall is separate, so banner can be taken out of the individual, published to some stringent requirements of the market.
(3). Oranges, temporarily also do not understand, there is the integral wall, looks like the money is relatively positive, many new platforms are very positive (casually picked a new platform foil foil bar)
Some people say, using aggregation, can use different advertising platform, I think this and this article discussion is a completely different two questions, here omitted 5,000 words.

3. Integrated architecture
Before we discuss the integration architecture, we have to discuss how apps and ads relate:
(1). Many to many relationships, an advertising platform will certainly be embedded in many applications, an application often also need to publish a number of advertising platform version.
(2). A one-to-many relationship, this one is contradictory to the first one, however, the advertising platform of the SDK itself is to solve the problem embedded in each application, and really have to consider a lot of options, it will be very cumbersome and not much value, so our focus is, an application to publish multiple advertising platform version.
(3). First advertising, after application, and then advertising platform. It means to start thinking about the integration of advertising, but just blank placeholder, where to show banner, where to display an application recommendation, leave a null method will interface, and then develop the application, after the application is completed, in considering how to integrate different advertising platform, according to different platforms to rewrite different ad placeholder, Or to display ads in different forms of advertising.
On the premise of these considerations, I draw the following integrated architecture diagram:

This frame composition is an example of a series of applications, not only for each application to release multiple ad versions, but also for a base library to encapsulate multiple applications, which should be a more typical example.

4. For example
I have already applied this idea to the World project, reference address: Https://github.com/openproject/world2
And after verification, the effect is good.
Of course, the specific ad placeholder and overwrite, I will omit here, you can also refer to the above address code.

5. Compile the problem
For different advertising platforms, we need to make some changes to the automatic compilation package script.
(1). The three-tier project uses the problem of ant compilation: R.java file generation and resource packaging.
The main thing to emphasize is to remind yourself not to make a mistake.
Generation of R.java, three-tier engineering is to be generated 3 times (build.xml):

Copy Code code as follows:

<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, with special attention to the order of resource folders:
Copy Code code as follows:

<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 compilation script (build.sh)
Copy Code code as follows:

#!/bin/bash

# get the file parent dir
basedir=$ (CD "$ (dirname" $) ";p wd)

# Get project name by dir name
project=$ (echo $basedir | awk-f "/" ' {print $NF} ')
project=${project/\.*/}

# Enter the right parent dir
CD $basedir

#markets = "WAPs Google official Appchina gfan QQ nduo feiliu 3g 360 zhuamob Baidu Sohu 163 Samsung Coolmart Meizu Moto Lian Tong iandroid imobile Xiaomi NearMe Dev "
markets= "Mumayi EO dev"
For market in $markets
Todo
echo packaging $project. v2.1_$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= $market
Done

These two scripts are executed under App.waps and can be put in place for general convenience, 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, a lot of places are a word with, if think some leap of thinking, hehe, please read the relevant articles.
This article is to use prior knowledge to solve the application of packaging multiple advertising platform version of the problem, share some attention to the place, hoping to help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.