Admob error "you must have AdActivity declared..."

edited March 2014 in Android Mode

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"/>

Tagged:

Answers

  • Take a look at this StackOverflow post. It looks like you're missing some of the values for configChanges...

  • edited March 2014

    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 :

    [aapt] C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\android4889435206698186700sketch\bin\AndroidManifest.xml:5: error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').
    
    BUILD FAILED
    C:\Program Files\Android\android-sdk\tools\ant\build.xml:653: The following error occurred while executing this line:
    C:\Program Files\Android\android-sdk\tools\ant\build.xml:698: null returned: 1
    
    Total time: 0 seconds
    

    What is interesting to see in log is :

    -build-setup: Using latest Build Tools: 19.0.3 [echo] Resolving Build Target for SoundAnalyzer... Project Target: Android 2.3.3 API level: 10

    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.

  • edited March 2014

    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.

  • edited March 2014

    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 :

    04-10 17:03:59.668: I/Ads(3972): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":2.0,"u_w":768,"slotname":"25987978989388","msid":"processing.test.poppers","js":"afma-sdk-a-v4.0.4","isu":"177A95CDD3DFD96C282915D15CB348E2","format":"320x50_mb","net":"wi","app_name":"4.0.4.android.processing.test.poppers","hl":"es","u_h":1184,"u_so":"p","u_audio":1});</script></head><body></body></html>
    04-10 17:03:59.668: W/WebView(3972): java.lang.Throwable: A WebView method was called on thread 'AsyncTask #1'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41e8c2c8} called on null, FYI main Looper is Looper (main, tid 1) {41e8c2c8})
    04-10 17:03:59.668: W/WebView(3972):    at android.webkit.WebView.checkThread(WebView.java:2063)
    04-10 17:03:59.668: W/WebView(3972):    at android.webkit.WebView.loadDataWithBaseURL(WebView.java:877)
    04-10 17:03:59.668: W/WebView(3972):    at c.a(Unknown Source)
    04-10 17:03:59.668: W/WebView(3972):    at c.doInBackground(Unknown Source)
    04-10 17:03:59.668: W/WebView(3972):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
    04-10 17:03:59.668: W/WebView(3972):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    04-10 17:03:59.668: W/WebView(3972):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    04-10 17:03:59.668: W/WebView(3972):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    04-10 17:03:59.668: W/WebView(3972):    at java.lang.Thread.run(Thread.java:841)
    

    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 ??

Sign In or Register to comment.