androidmillennial-media

java.lang.NoClassDefFoundError: com.millennialmedia.android.MMAdView


I am Using Millenial media in my app. i have several apps running with following code but now when i try to copy paste running code for new apps it shows the error java.lang.NoClassDefFoundError: com.millennialmedia.android.MMAdView

this is how i am creating MMAdView object and inserting it in my Linear Layout.

LinearLayout myLayout = (LinearLayout) findViewById(R.id.layoutadd);
adview = new MMAdView(MyClass.this, MYAPID,"MMBannerAdBottom", 30);
myLayout.addView(adview, new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
MMAdListener listener = new MyAdListener();
adview.setListener(listener);
adview.callForAd();

this is the xml declaration

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.xxx"
    android:versionCode="1"
    android:versionName="1.0" 
    android:installLocation="auto">

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MyClass"
            android:label="@string/app_name"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.millennialmedia.android.MMAdViewOverlayActivity">
        </activity>
        <activity android:name="com.millennialmedia.android.VideoPlayer" 
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:configChanges="keyboardHidden|orientation|keyboard" >
        </activity>
    </application>
    <uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>

i have also imported liabrary...

THIS THING IS WORKING IN MY OTHER APPS JUST IS THAT FROM FEW DAYS ITS NOT WORKING PROPERLY FOR NEW APPS.


Solution

  • This usually happens when the JAR file isn't copied onto the device. On Millennial Media's wiki page, they show you how to add the JAR to your project. After you select the library (9th bullet point), but before you hit "OK", go to the "Order and Export" tab and make sure the checkbox next to MMAdView.jar is checked. By default, it isn't. Push OK and try running your program.