androidnoclassdeffounderroradwhirl

NoClassDefFoundError: AdWhirlLayout


i checked similar question on the forum, but couldn't get it to run. Finally i removed everything not needed to focused on the error and i left with that chunk of code. But it's still crashing with a NoClassDefFoundError at the

AdWhirlLayout adWhirlLayout = new AdWhirlLayout(TestActivity.this, key);

line.

I'am using AdWhirlSDK_Android_3.1.1 but tried as well the AdWhirlSDK_Android_3.0.0. I've got the same error.

Java Code.

import com.adwhirl.AdWhirlLayout;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.LinearLayout.LayoutParams;

public class TestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        setupAds();
    }

    private void setupAds() {
        String key = "adwhirl_key";

        int diWidth = 320;
        int diHeight = 52;
        float density = getResources().getDisplayMetrics().density;

        LinearLayout layout = (LinearLayout) findViewById(R.id.adView);
        RelativeLayout.LayoutParams layoutParams = 
                new RelativeLayout.LayoutParams(
                        LayoutParams.FILL_PARENT, 
                        LayoutParams.WRAP_CONTENT);

        AdWhirlLayout adWhirlLayout = new AdWhirlLayout(TestActivity.this, key);
        adWhirlLayout.setMaxWidth((int) (diWidth * density));
        adWhirlLayout.setMaxHeight((int) (diHeight * density));

        layout.addView(adWhirlLayout, layoutParams);
        layout.invalidate();
    }
}

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <LinearLayout
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

LOGCAT:

04-11 17:59:50.451: E/AndroidRuntime(707): FATAL EXCEPTION: main
04-11 17:59:50.451: E/AndroidRuntime(707): java.lang.NoClassDefFoundError: com.adwhirl.AdWhirlLayout
04-11 17:59:50.451: E/AndroidRuntime(707):  at com.testproject.TestActivity.setupAds(TestActivity.java:34)
04-11 17:59:50.451: E/AndroidRuntime(707):  at com.testproject.TestActivity.onCreate(TestActivity.java:18)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.os.Looper.loop(Looper.java:123)
04-11 17:59:50.451: E/AndroidRuntime(707):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-11 17:59:50.451: E/AndroidRuntime(707):  at java.lang.reflect.Method.invokeNative(Native Method)
04-11 17:59:50.451: E/AndroidRuntime(707):  at java.lang.reflect.Method.invoke(Method.java:507)
04-11 17:59:50.451: E/AndroidRuntime(707):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-11 17:59:50.451: E/AndroidRuntime(707):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-11 17:59:50.451: E/AndroidRuntime(707):  at dalvik.system.NativeStart.main(Native Method)

Has anybody an idea and can tell my what i cant see.Please.

Best Regards


Solution

  • You should definitely check the link in your comments. Basically you need to handle all of your dependencies in android by putting the required libraries in a "libs" folder. Eclipse doesn't generate this automatically for you, so you have to make it yourself. Put the "libs" folder in the "res" folder (not bin/res, the res folder that shares the same directory as src).

    Also make sure you have all the proper declarations in your manifest if you are launching other activities, need special permissions for those functions (uses-internet), etc.