We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm trying to integrate AdMob to my Processing sketch with Android Mode. I've followed instructions from two sources: http://www.bitator.com/2013/05/admob-ads-in-processing-einbinden/ http://forum.processing.org/one/topic/admob-error-you-must-have-adactivity-declared-in-androidmanifest-xml-with-configchanges.html
I think I've done everything according to this guides, but I still see only small rectangle with error text: "You must have AdActivity declared in AndroidManifest.xml with configChanges"
I've added GoogleAdMobAdsSdkAndroid-6.4.1 to my project and added to code and changed AndroidManifest.xml. I still get this error... Any advice ?
I'd also like to ask whether we can integrate newer Ad service as Google play service? Is this a preffered way - do we have any working examples ?
Thanks in advance, regards Bulek.
Snippets of added code to my .pde file :
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.RelativeLayout;
import com.google.ads.*;
...
@Override
public void onCreate(Bundle savedInstanceState) {
println(millis()/1000.0 + " Inside onCreate(Bundle savedInstanceState)!");
super.onCreate(savedInstanceState);
Window window = getWindow();
RelativeLayout adsLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
// Displays Ads at the bottom of your sketch, use Gravity.TOP to display them at the top
adsLayout.setGravity(Gravity.TOP);
AdView adView = new AdView(this, AdSize.BANNER, ADMOB_ID); // add your app-id
adsLayout.addView(adView);
AdRequest newAdReq = new AdRequest();
// Remark: uncomment next line for testing your Ads (fake ads)
newAdReq.setTesting(true);
adView.loadAd(newAdReq);
window.addContentView(adsLayout,lp2);
}
AndroidManifest.xml
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="13"/>
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="">
<activity
android:name=""
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode"
android:name="com.google.ads.AdActivity"/>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
Answers
Take a look at this StackOverflow post. It looks like you're missing some of the values for
configChanges
...hi,
thanks for response... The link you provided leads to very informative source.
I had to remove last two config entries "|screenSize|smallestScreenSize", cause I got another error - something like "string argument is not allowed in configChanges"... And I found advice, to remove last two entries and error did go away, but still I get error about non-existent AdActivity after that...
I've checked this again. Set android:minSdkVersion="10" android:targetSdkVersion="13"/>
added those two settings and tried to compile. And I got error :
What is interesting to see in log is :
It seems that API 10 is always used for building... And under API 10, those parameters are not properly parsed and recognized. I've installed API 13 on Android sdk.
I suspect that there is a problems regarding API levels. As I've read, Processing needs API 10, AdMob claims need for API 13 and I'm not sure if I'm able to compile stuff under Processing and Android target with higher level than 10 ?
That post in German claims that procedure works even under Processing, but I'm not sure what am I doing wrong or maybe something else changed in the mean time...
Anyone successfully using AdMob in Processing sketches under Android target ?
Thanks in advance, regards, Bulek.
The post in German was likely written for an older version of the AdMob SDK. Indeed, Processing has hard-coded the target API level to 10 (I had forgotten about this), which will certainly cause problems with AdMob.
If it is an option, you can move the project into Eclipse ADT (this normally comes with the Android SDK) via Processing's Export Android Project tool.
Your best chance may be to get hold of an older version of the AdMob SDK. I don't know how you would go about doing this, however.
All you have to do is export and in the android directory will be a file named project.properties The first line will say:
"target=android-10"
change that number to 17 or the highest android api version you have (i think 13 is good with the latest version of admob but am not positive) From this point you have to build your android project with ant or eclipse you cant use pde. So i always add ads after my project is finished.
PS: i used the following post with what i said above, Im not sure about the links you provided i cant read german lol.
forum.processing.org/one/topic/how-to-including-ads-to-android-project.html
Hi exithead, I've tried to do what you said, and I changed the project.properties with target=android-13. This way I managed to build the .apk with the long line (including "|screenSize|smallestScreenSize") using the command ant debug. Installed the app... but... still got the 'You must have AdActivity declared in AndroidManifest.xml with configChanges' error where the ad should be... Could you please clarify how do you build the project with ant ? Am I missing something ?
The story so far:
I've managed to compile with no errors, but the ads are not showing. Where I had the banner with the error : 'You must have AdActivity declared in AndroidManifest.xml with configChanges', now this does not appear; nothing appears.
I've imported the built project (built with ant debug, so I could make use of API 13) into Eclipse, and now I can see the errors in the LogCat. Looks like it's fetching the ads properly, but I have error when showing them :
I've also tried different versions of the Admob SDK, but still the same.
So... could anyone that has managed to make admob work please advice ??