请帮助我不知道我做错了什么我已经使用了很多教程。
这是我的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);
}
}
这是我的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>
这是我的android xml
我看过很多教程并试图实现它们,但是每个教程都会导致我的应用程序崩溃,而且我不知道该怎么做。
修改:
这是我尝试运行时为应用程序获取的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
修改:
这就是我的问题标签所说的
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
答案 0 :(得分:0)
您正在呼叫initialze
和initializeForView
。你应该只调用一个,很可能是initializeForView
。
答案 1 :(得分:0)
如果这是一个Eclipse项目,请尝试以下方法:
右键点击游戏的Android project
,转到Android Tools
,然后按Add Support Library
。
如果这是一个Gradle项目,则需要将android支持v4库作为依赖项添加到build.gradle中,假设使用行compile 'com.android.support:support-v4:13.0.+'