简体   繁体   English

每当我尝试在libgx上投放广告时,应用都会崩溃

[英]Everytime I try and put ads on my libgx, the app crashes

Please help I dont know what I'm doing wrong I have used alot of tutorials. 请帮助我不知道我在做什么错,我已经使用了很多教程。

This my Android extension code 这是我的Android扩展代码

package com.EmekaEzekwem.BrodyJump.android;
import android.app.Dialog;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import.android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

import com.EmekaEzekwem.BrodyJump.BrodyJump;

public class AndroidLauncher extends AndroidApplication {


@Override
public void onCreate (Bundle savedInstanceState) {

    /*protected usually*/

    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();

    initialize(new BrodyJump(), cfg);
    // Create the layout
    RelativeLayout layout = new RelativeLayout(this);

    // Do the stuff that initialize() would do for you
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    // Create the libgdx View
    View gameView = initializeForView(new BrodyJump(), cfg);

    // Create and setup the AdMob view
    AdView adView = new AdView(this);
    adView.setAdUnitId("for posting");
    adView.setAdSize(AdSize.BANNER);
    adView.loadAd(new AdRequest.Builder().build());
    // Add the libgdx view
    layout.addView(gameView);

    // Add the AdMob view
    RelativeLayout.LayoutParams adParams = 
        new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                RelativeLayout.LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    layout.addView(adView, adParams);

    // Hook it all up
    setContentView(layout);
}    



}

This is my android manifest xml 这是我的Android清单xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.andriod.com/apk/lib/com.google.ads"
package="com.EmekaEzekwem.BrodyJump.android"
android:versionCode="11"
android:versionName="11.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/BrodyJump"
    android:theme="@style/GdxTheme" >
    <activity android:name="com.google.android.gms.ads.AdActivity"


     andriod config changes are here too but this website wont let me post it                            

    <activity
        android:name="com.EmekaEzekwem.BrodyJump.android.AndroidLauncher"
        android:label="@string/BrodyJump" 
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">



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


            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

This is my android xml 这是我的android xml

I have seen many tutorials and tried to implement them, but each one just causes my app to crash and I don't know what to do. 我看过很多教程并尝试实现它们,但是每一个都只会导致我的应用崩溃,而我不知道该怎么做。

EDIT : 编辑

This is the logcat that I am getting for the app when I try run it: 这是我尝试运行该应用程序时得到的logcat:

08-05 15:20:13.574: D/dalvikvm(26758): Trying to load lib /data/app-lib/com.EmekaEzekwem.BrodyJump.android-2/libgdx.so 0x4298c920
08-05 15:20:13.574: D/dalvikvm(26758): Added shared lib /data/app-lib/com.EmekaEzekwem.BrodyJump.android-2/libgdx.so 0x4298c920
08-05 15:20:13.574: D/dalvikvm(26758): No JNI_OnLoad found in /data/app-lib/com.EmekaEzekwem.BrodyJump.android-2/libgdx.so 0x4298c920, skipping init
08-05 15:20:13.574: W/ApplicationPackageManager(26758): getCSCPackageItemText()
08-05 15:20:13.594: I/Adreno-EGL(26758): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
08-05 15:20:13.594: I/Adreno-EGL(26758): OpenGL ES Shader Compiler Version: 17.01.11.SPL
08-05 15:20:13.594: I/Adreno-EGL(26758): Build Date: 01/17/14 Fri
08-05 15:20:13.594: I/Adreno-EGL(26758): Local Branch: 
08-05 15:20:13.594: I/Adreno-EGL(26758): Remote Branch: 
08-05 15:20:13.594: I/Adreno-EGL(26758): Local Patches: 
08-05 15:20:13.594: I/Adreno-EGL(26758): Reconstruct Branch: 
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8177 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x0083
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8172 (common_google_play_services_enable_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x008e
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8192 (common_google_play_services_update_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x0099
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8189 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x00ab
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8182 (common_google_play_services_network_error_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x00bd
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8179 (common_google_play_services_invalid_account_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x00e7
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve static field 8189 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x60 at 0x0106
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
08-05 15:20:13.664: E/dalvikvm(26758): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.b
08-05 15:20:13.664: W/dalvikvm(26758): VFY: unable to resolve instanceof 165 (Landroid/support/v4/app/FragmentActivity;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
08-05 15:20:13.664: D/dalvikvm(26758): VFY: replacing opcode 0x20 at 0x0008
08-05 15:20:13.664: E/dalvikvm(26758): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.b

EDIT : 编辑

This is what my problem tab say 这就是我的问题标签所说的

Description Resource    Path    Location    Type
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   GoogleAdsSampleActivity     Build path  Build Path Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   PlusSampleActivity      Build path  Build Path Problem
    Unable to resolve target 'android-9'    google-play-services_lib        Unknown Android Target Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    RealtimePlaygroundHomeActivity      Unknown Java Problem
    The project cannot be built until build path errors are resolved    GoogleAdsSampleActivity     Unknown Java Problem
    Unable to resolve target 'android-9' until the SDK is loaded.   google-play-services_lib        Unknown Android Target Problem
    error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml  /AnimalSounds/res/values-v11    line 7  Android AAPT Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    UnusedStub.java /google-play-services_lib/src/android   line 1  Java Problem
    Unable to resolve target 'android-9' until the SDK is loaded.   PlusSampleActivity      Unknown Android Target Problem
    Unable to resolve target 'android-18'   GoogleAdsSampleActivity     Unknown Android Target Problem
    Unable to resolve target 'android-9'    PanoramaSampleActivity      Unknown Android Target Problem
    Unable to resolve target 'android-18' until the SDK is loaded.  GoogleAdsSampleActivity     Unknown Android Target Problem
    The project cannot be built until build path errors are resolved    AnimalSounds        Unknown Java Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    ListenChangeEventsForFilesActivity.java /HomeActivity/src/com/google/android/gms/drive/sample/demo/events   line 1  Java Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    GooglePlayServicesActivity      Unknown Java Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   MainActivity        Build path  Build Path Problem
    Unable to resolve target 'android-9' until the SDK is loaded.   MainActivity        Unknown Android Target Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   BrodyJump-android       Build path  Build Path Problem
    The project cannot be built until build path errors are resolved    ItemListActivity        Unknown Java Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    TimingFragment.java /MobilePlayground/src/com/google/android/gms/analytics/samples/mobileplayground line 1  Java Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    MobilePlayground        Unknown Java Problem
    /ItemListActivity/gen already exists but is not a source folder. Convert to a source folder or rename it.   ItemListActivity        line 1  Android ADT Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   PanoramaSampleActivity      Build path  Build Path Problem
    The project cannot be built until build path errors are resolved    ModeSelectActivity      Unknown Java Problem
    error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml  /AnimalSounds/res/values    line 7  Android AAPT Problem
    /ModeSelectActivity/gen already exists but is not a source folder. Convert to a source folder or rename it. ModeSelectActivity      line 1  Android ADT Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    GameTrack.java  /GooglePlayServicesActivity/java/com/example/activitydemo/app/service   line 1  Java Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   GameActivity        Build path  Build Path Problem
    The project cannot be built until build path errors are resolved    BrodyJump-android       Unknown Java Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    SplashScreenActivity        Unknown Java Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   ItemListActivity        Build path  Build Path Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   AnimalSounds        Build path  Build Path Problem
    The project cannot be built until build path errors are resolved    MainActivity        Unknown Java Problem
    Unable to resolve target 'android-9'    MainActivity        Unknown Android Target Problem
    /GameActivity/gen already exists but is not a source folder. Convert to a source folder or rename it.   GameActivity        line 1  Android ADT Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    Utils.java  /SplashScreenActivity/src/com/google/android/tagmanager/examples/cuteanimals    line 1  Java Problem
    The project cannot be built until build path errors are resolved    PanoramaSampleActivity      Unknown Java Problem
    Unable to resolve target 'android-9'    PlusSampleActivity      Unknown Android Target Problem
    error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.   styles.xml  /AnimalSounds/res/values-v14    line 8  Android AAPT Problem
    The project cannot be built until build path errors are resolved    GameActivity        Unknown Java Problem
    Unable to resolve target 'android-9' until the SDK is loaded.   PanoramaSampleActivity      Unknown Android Target Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    google-play-services_lib        Unknown Java Problem
    The container 'Android Dependencies' references non existing library 'C:\Users\Chuka\Downloads\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\extras\google\google_play_services\libproject\google-play-services_lib\bin\google-play-services_lib.jar'   ModeSelectActivity      Build path  Build Path Problem
    The project cannot be built until build path errors are resolved    PlusSampleActivity      Unknown Java Problem
    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project    HomeActivity        Unknown Java Problem
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files    RealtimePlaygroundHomeActivity.java /RealtimePlaygroundHomeActivity/src/com/google/android/gms/drive/sample/realtimeplayground  line 1  Java Problem

You are calling initialze AND initializeForView . 您正在调用initialzeinitializeForView You should only be calling one, most likely initializeForView . 您应该只调用一个,很可能是initializeForView

If this is an Eclipse project, then try the following: 如果这是一个Eclipse项目,请尝试以下操作:

Right click the Android project of the game, go to Android Tools , then press Add Support Library . 右键单击游戏的Android project ,转到Android Tools ,然后按Add Support Library

If this is a Gradle project, then the android support v4 library needs to be added to the build.gradle as a dependency, supposedly with the line compile 'com.android.support:support-v4:13.0.+' 如果这是一个Gradle项目,则需要将Android支持v4库作为依赖项添加到build.gradle中,应该使用compile 'com.android.support:support-v4:13.0.+'compile 'com.android.support:support-v4:13.0.+'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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