Millennial Media integration android - noSuchMethod: getRealMetrics

866 Views Asked by At

Just trying to integrate the MillennialMedia ad network to monetize my app. I did everything like it has to be. But it gives me this error in logcat (I googled like 1h and didn´t find anyone else with this problem...):

05-25 23:00:14.437: E/MMSDK-MMSDK(29250): Error calling getRealMetrics: java.lang.NoSuchMethodException: getRealMetrics []
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at java.lang.Class.getConstructorOrMethod(Class.java)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at java.lang.Class.getMethod(Class.java)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getMetrics(MMSDK.java:1075)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getDensity(MMSDK.java:742)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getDensityString(MMSDK.java:736)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.insertUrlCommonValues(MMSDK.java:877)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.HandShake$1.run(HandShake.java:333)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
05-25 23:00:14.437: E/MMSDK-MMSDK(29250):   at java.lang.Thread.run(Thread.java)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250): Error calling getRealMetrics: java.lang.NoSuchMethodException: getRealMetrics []
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at java.lang.Class.getConstructorOrMethod(Class.java)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at java.lang.Class.getMethod(Class.java)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getMetrics(MMSDK.java:1075)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getDpiHeight(MMSDK.java:1094)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.insertUrlCommonValues(MMSDK.java:878)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.HandShake$1.run(HandShake.java:333)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
05-25 23:00:14.442: E/MMSDK-MMSDK(29250):   at java.lang.Thread.run(Thread.java)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250): Error calling getRealMetrics: java.lang.NoSuchMethodException: getRealMetrics []
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at java.lang.Class.getConstructorOrMethod(Class.java)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at java.lang.Class.getMethod(Class.java)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getMetrics(MMSDK.java:1075)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.getDpiWidth(MMSDK.java:1065)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.MMSDK.insertUrlCommonValues(MMSDK.java:879)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at com.millennialmedia.android.HandShake$1.run(HandShake.java:333)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
05-25 23:00:14.447: E/MMSDK-MMSDK(29250):   at java.lang.Thread.run(Thread.java)
05-25 23:00:14.447: E/MMSDK-HandShake(29250): Could not get a handshake. : java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at com.millennialmedia.android.MMSDK.insertUrlCommonValues(MMSDK.java:893)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at com.millennialmedia.android.HandShake$1.run(HandShake.java:333)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
05-25 23:00:14.447: E/MMSDK-HandShake(29250):   at java.lang.Thread.run(Thread.java)

That was my logcat, and here comes my code I used:

MMSDK.initialize(this);

    MMRequest request = new MMRequest();
    interstitial = new MMInterstitial(this);
    interstitial.setMMRequest(request);
    interstitial.setApid("163665");
    interstitial.setListener(new RequestListenerImpl() {
        @Override
        public void requestCompleted(MMAd mmAd) {
           interstitial.display();
        }
    });
    interstitial.fetch();

So thats my code, and I totally don´t know what is false. Could someone explain me my faults? That would be very nice from you. Thanks.

3

There are 3 best solutions below

0
On

Sorry guys, i suddenly don´t had this:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

    <activity android:name="com.millennialmedia.android.MMActivity"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" 
    android:configChanges="keyboardHidden|orientation|keyboard" ></activity>

in my manifest so it didnt worked... I don´t know why, but now my app displays ads! The error is still there like andy said, but if all the necessary things work... Thanks to all especially to onik who reminded me looking into my manifest!

0
On

For anyone else who has these errors:

I emailed customer service and they that that the errors show up on newer versions of Android (4.4+ i think) but they dont affect the ads from loading or displaying

1
On

In version 5.2 of Millennial's Android SDK, it reaches methods added in later versions of the Android SDK through introspection and logs out Exceptions to logcat for transparency and debugging purposes.

You may also see similar Exceptions in your logcat for setMediaPlaybackRequiresUserGesture or setLayerType depending on the version of the Android SDK being compiled against and the actual handset's Android version.

Anyway, all of these are handled exceptions: They won't crash any apps or upset any crash reporting services. And, despite the volume and noise, they don't affect user experience.

There have been more than a handful of e-mails pointing this out, we're taking the hint and making some changes for 5.3.

If anyone needs more information, throw feel free to contact Millennial here-- https://tools.mmedia.com/user/supportDevPortal