简体   繁体   中英

Banner ad crashing android ap

For some reason this line

adView = new AdView(this, AdSize.BANNER, "xxxxxx");//adUnitId is actually there

is crashing my android app ever time I try to run it.

I put in the GoogleAdMod jar file, but nothing has come of it

project.properties

target=android-16

AndroidManifest

<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

I've been at this for house and have tried approaches through xml and classes, but I am stumped.

Thanks in advance

-Ben

edit: logs

02-02 18:51:14.028: W/IInputConnectionWrapper(11019): getSelectedText on inactive InputConnection
02-02 18:51:14.028: W/IInputConnectionWrapper(11019): setComposingText on inactive InputConnection
02-02 18:51:18.693: I/Choreographer(11019): Skipped 32 frames!  The application may be doing too much work on its main thread.
02-02 18:51:18.763: E/dalvikvm(11019): Could not find class 'com.google.ads.AdView', referenced from method com.ben.fishbein.tictacception.free.Online_home_free.onCreate
02-02 18:51:18.763: W/dalvikvm(11019): VFY: unable to resolve new-instance 457 (Lcom/google/ads/AdView;) in Lcom/ben/fishbein/tictacception/free/Online_home_free;
02-02 18:51:18.763: D/dalvikvm(11019): VFY: replacing opcode 0x22 at 0x0017
02-02 18:51:18.763: I/dalvikvm(11019): DexOpt: unable to optimize static field ref 0x0810 at 0x19 in Lcom/ben/fishbein/tictacception/free/Online_home_free;.onCreate
02-02 18:51:18.773: D/dalvikvm(11019): DexOpt: unable to opt direct call 0x0d0f at 0x1d in Lcom/ben/fishbein/tictacception/free/Online_home_free;.onCreate
02-02 18:51:18.773: D/AndroidRuntime(11019): Shutting down VM
02-02 18:51:18.773: W/dalvikvm(11019): threadid=1: thread exiting with uncaught exception (group=0x411ae438)
02-02 18:51:18.783: E/AndroidRuntime(11019): FATAL EXCEPTION: main
02-02 18:51:18.783: E/AndroidRuntime(11019): java.lang.NoClassDefFoundError: com.google.ads.AdView
02-02 18:51:18.783: E/AndroidRuntime(11019):    at com.ben.fishbein.tictacception.free.Online_home_free.onCreate(Online_home_free.java:82)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.Activity.performCreate(Activity.java:5048)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2052)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.ActivityThread.access$700(ActivityThread.java:139)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.os.Looper.loop(Looper.java:137)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at android.app.ActivityThread.main(ActivityThread.java:4918)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at java.lang.reflect.Method.invokeNative(Native Method)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at java.lang.reflect.Method.invoke(Method.java:511)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
02-02 18:51:18.783: E/AndroidRuntime(11019):    at dalvik.system.NativeStart.main(Native Method)



public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.free_online_home);
    bigBoard = (RelativeLayout) findViewById(R.id.rlBigBoard);

    adView = new AdView(this,  AdSize.BANNER, "aasd0");
            //new AdView(this, AdSize.BANNER, "asdsd");
//  bigBoard.addView(adView);
    //adView.loadAd(new AdRequest());

    // AdView ad = (AdView) findViewById(R.id.adView);
    //ad.loadAd(new AdRequest());
    //initialize();
}

如果GoogleAdMobAdsSdk位于您的参考库中,则文件顺序错误,请确保该文件位于src或res文件夹之前的顶部。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM