Sina Weibo 2.5.1 for Android ads tutorial

Source: Internet
Author: User

The night is quiet. If you can't sleep, you can write something.
Recently, my mobile phone's Sina Weibo was updated to version 2.5.1, so I started to advertise. I can't afford to hurt it...
Dear user, no, there's just a small cell phone screen, and stuff in it. In addition, it's an AdCenter service running in the background.
 
 



The required tools are: apktool, JD-GUI, dex2jar, Apk file signature Tool
Dex2jar: http://laichao.googlecode.com/files/...7-SNAPSHOT.zip
JD-GUI:
Windows JD-GUI: http://laichao.googlecode.com/files/jdgui.zip
Linux JD-GUI: http://laichao.googlecode.com/files/...ux.i686.tar.gz
Apktool:
Http://code.google.com/p/android-apktool/
Apk file signature tool:
Baidu
1. first, extract the downloaded Sina Weibo apk program with the decompression tool (winrar). The extracted directory contains a classes. dex file, decompile it into jar with dex2jar.

2. Open the jar file with the JD-GUI, find com. sina. weibo \ HomeListActivity, open the direct view of the Code... (Find the key part of the advertisement and search for keywords as needed, such as AdView)
It is easy to see in the protected void onCreate (Bundle paramBundle) function the code in the initialization advertisement window:

IntentFilter localIntentFilter3 = new IntentFilter ();
LocalIntentFilter3.addAction ("com. sina. weibo. action. AdCenter. show ");
BroadcastReceiver localBroadcastReceiver3 = this. mAdReceiver;
Intent localIntent3 = registerReceiver (localBroadcastReceiver3, localIntentFilter3 );
InitAdView ();

InitAdView:
Private void initAdView ()
{
Animation localAnimation1 = AnimationUtils. loadAnimation (this, 2130968576 );
This. mAdInAnimation = localAnimation1;
Animation localAnimation2 = AnimationUtils. loadAnimation (this, 2130968577 );
This. mAdOutAnimation = localAnimation2;
ImageView localImageView1 = (ImageView) findViewById (2131624038 );
This. mAdBar1 = localImageView1;
ImageView localImageView2 = (ImageView) findViewById (2131624039 );
This. mAdClose1 = localImageView2;
ImageView localImageView3 = (ImageView) findViewById (2131624040 );
This. mAdBar2 = localImageView3;
ImageView localImageView4 = (ImageView) findViewById (2131624041 );
This. mAdClose2 = localImageView4;
HomeListActivity.14 local14 = new HomeListActivity.14 (this );
HomeListActivity.15 local15 = new HomeListActivity.15 (this );
This. mAdBar1.setOnClickListener (local14 );
This. mAdClose1.setOnClickListener (local15 );
This. mAdBar2.setOnClickListener (local14 );
This. mAdClose2.setOnClickListener (local15 );
}
Therefore, it is very easy to go to the advertisement. You only need to drop the onCreate five-line code to NOP. However, if the five-line code is nop, the advertisement will go, but when you exit, the Weibo client will still crash. The reason is that onCreate registers a broadcast receiver but is dropped by NOP. However, when the window is destroyed, this broadcast receiver is removed from the protected void onDestroy () function, so it causes a crash. Therefore, the code in the onDestroy function must be nop!

BroadcastReceiver localBroadcastReceiver2 = this. mAdReceiver;
UnregisterReceiver (localBroadcastReceiver2 );

3. use apktool to decompile the apk program of sina weibo. In the decompiled program directory, find smali \ com \ sina \ weibo \ HomeListActivity. smali file, which can be opened directly in notepad. Search "com. sina. weibo. action. AdCenter. show" to locate the onCreate function and delete the following lines.

. Line 329
New-instance v1, Landroid/content/IntentFilter;
Invoke-direct {v1}, Landroid/content/IntentFilter;-> <init> () V

. Line 330
. Local v1, myAdIntentFilter: Landroid/content/IntentFilter;
Const-string v3, "com. sina. weibo. action. AdCenter. show"
Invoke-virtual {v1, v3}, Landroid/content/IntentFilter;-> addAction (Ljava/lang/String;) V

. Line 331
Iget-object v3, p0, Lcom/sina/weibo/HomeListActivity;-> mAdReceiver: Landroid/content/BroadcastReceiver;
Invoke-virtual {p0, v3, v1}, Lcom/sina/weibo/HomeListActivity;-> registerReceiver (Landroid/content/BroadcastReceiver; Landroid/content/IntentFilter ;) landroid/content/Intent;

. Line 334
Invoke-direct {p0}, Lcom/sina/weibo/HomeListActivity;-> initAdView () V

Search for "protected onDestroy ()" and find the onDestroy function. Delete these lines!
. Line 808
Iget-object v0, p0, Lcom/sina/weibo/HomeListActivity;-> mAdReceiver: Landroid/content/BroadcastReceiver;
Invoke-virtual {p0, v0}, Lcom/sina/weibo/HomeListActivity;-> unregisterReceiver (Landroid/content/BroadcastReceiver;) V

4. Delete the ADCenter service! Otherwise, this service will always run in the background, and it will hurt somewhere! Open the AndroidManifest. xml file under the program directory decompiled by the apk program on Sina Weibo. Delete the following lines to remove the AdCenter service.

<Service android: name = ". business. AdCenter">
<Intent-filter>
<Action android: name = "com. sina. weibo. action. speed"/>
<Category android: name = "android. intent. category. DEFAULT"/>
</Intent-filter>
</Service>

5. Use apktool to compile the program directory decompiled on Sina Weibo after the advertisement is modified into an apk file. Finally, add a signature to the advertisement version.
 
ZzAge [LCG] [80DFJ]

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.