在iOS SDK 4.2的MonoTouch项目中使用AdMob
我们有一个测试项目尝试将AdMob与MonoTouch一起使用.设置如下:
我们创建了一个(胖)TouchJSON库,如TouchJSON的Monotouch绑定中所述?
我们有一个Libs库,其中包含此libTouchJSON.a和AdMob提供的libAdMobNoThumb.a库.在那里,我还有一个来自AdMob.cs文件的btouch的AdMob.dll,它定义了我们想要使用的(有限的一组)Admob方法.此dll将添加到项目的引用中
我们提供以下额外标志:
-v -v -v -gcc_flags "-L${ProjectDir}/../Libs -lAdMobNoThumb -lTouchJSON -force_load ${ProjectDir}/../Libs/libAdMobNoThumb.a -force_load ${ProjectDir}/../Libs/libTouchJSON.a"
Run Code Online (Sandbox Code Playgroud)
我们选择"不链接"作为链接器行为.
这曾经使用了admob库的SDK 4.2之前的版本.但现在有了4.2版本,我们得到了
ld: framework not found AudioUnit
Run Code Online (Sandbox Code Playgroud)
错误.我们已经读过,解决方案是"重新启动链接器".但是如果我们进行链接(如上所述保留其余的设置),我们会从admob库中获得许多未知符号:
Error 1: mtouch failed with the following message:
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m: In function 'monotouch_debug_connect':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1779: warning: implicit declaration of function 'select'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m: In function 'main':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1821: warning: implicit declaration of function 'chdir'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1838: warning: implicit declaration of function 'monotouch_enable_debug_tracking'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1914: warning: implicit declaration of function 'dup2'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1921: warning: implicit declaration of function 'mini_get_debug_options'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1925: …Run Code Online (Sandbox Code Playgroud) adMob工作正常,直到我将eclipse更新到最新版本,现在启动时报告错误,java.lang.NoClassDefFoundError:com.google.ads.AdRequest.但adMob库附加到项目!! 谢谢.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
adRequest.addTestDevice("3xxxxxxxxxx");
AdView adView = new AdView(this, AdSize.BANNER, "axxxxxxxxxx");
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
Run Code Online (Sandbox Code Playgroud)
清单上的适当参考和权限
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Run Code Online (Sandbox Code Playgroud) 我得到这个错误:
- The type AdListener cannot be a superinterface of AdManager; a superinterface must be an
interface
Run Code Online (Sandbox Code Playgroud)
当我尝试在我的应用上实施ADMOB AdListener时:
import com.google.android.gms.ads.AdListener;
public class AdManager implements AdListener{
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我已成功为我的iOS应用整合了插页式广告.我知道广告视图中有一个关闭按钮,我们可以在点击该按钮后将其关闭.
但我希望在3秒后以编程方式关闭此广告视图.但我不知道解雇此广告的方法是什么.
- - 更新 - - -
- (void)viewDidLoad
{
[super viewDidLoad];
singletonClassObject=[Singleton SharedManager];
//--------ADMOB FULLSCREEN----------
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.delegate = self;
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-3940256099942544/4411468910";
GADRequest *request = [GADRequest request];
// Requests test ads on simulators.
request.testDevices = @[ GAD_SIMULATOR_ID, @"MY_TEST_DEVICE_ID" ];
[self.interstitial loadRequest:request];
//--------END OF AD MOB FULLSCREEN---------
}
Run Code Online (Sandbox Code Playgroud)
这是在点击活动中展示广告的方式
if ([self.interstitial isReady]) {
[self.interstitial presentFromRootViewController:self];
}
Run Code Online (Sandbox Code Playgroud)
这些是在app解雇,显示等时触发的代表
/// Called when an interstitial ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
NSLog(@"interstitialDidReceiveAd"); …Run Code Online (Sandbox Code Playgroud) 通过向我的应用添加adMob横幅,我遇到了一个奇怪的问题.这是我第一次使用android studio,所以我跟着教程(唯一不同的是build.gradle文件的编辑).
我一如既往地为布局添加横幅:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_cut"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/banner" />
<com.google.android.gms.ads.AdView
android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admob_id" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
并将横幅初始化为我的活动:
AdView mAdView = (AdView) findViewById(R.id.banner);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)
现在,当我启动我的应用程序时,横幅空间是空的,我得到一些警告,如
W/Ads? Not enough space to show ad. Needs 360x50 dp, but only has 328x479 dp.
Run Code Online (Sandbox Code Playgroud)
但是日志告诉我横幅已正确加载:
I/Ads? Scheduling ad refresh 40000 milliseconds from now.
I/Ads? Ad finished loading.
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
我想在屏幕底部放置一个adMob AdView。但是广告在ListView的最后一项上重叠,因此我看不到ListView的最后一项。如果我使用android:layout_below =“ @ + id / list_view”。广告没有加载!
如何将ListView放在AdView的正上方?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:scrollingCache="false"
android:animationCache="false"
android:smoothScrollbar="true"
android:stretchMode="columnWidth">
</ListView>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/list_view"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/ads_banner">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序准备在商店发布,我已经使用Admob的Banner Ads,我最近一直在使用测试ID.我有我的Admob ID,但是我可以用真实ID更新测试ID并在模拟器上运行一次以更新代码吗?据我所知,在模拟器上没有再次运行项目之前,更改不会反映在.apk文件中.
我担心,因为这是一个实况广告,我不能将它用于开发目的.此外,为了让应用与实时广告合作,我需要做出哪些更改?任何帮助将受到高度赞赏.
我已经查看了答案,但似乎找不到GADInterstitialDelegate的答案。
我正在学习该教程:https : //developers.google.com/admob/ios/interstitial,但我得到的只是这个错误:
无法将类型“ ViewController”的值分配给类型“ GADInterstitialDelegate?”
我已删除该项目,然后重新开始。有人可以帮忙吗?
我想知道我的Android应用程序之一在我在Google Play控制台中选中“主要面向儿童”并选择加入“为家庭设计”后将不再显示广告,有人对此事有想法吗?
最好的问候,维拉克
admob ×10
android ×6
google-admob ×2
java ×2
eclipse ×1
ios ×1
iphone ×1
monodevelop ×1
swift ×1
touchjson ×1
xamarin.ios ×1
xml ×1