所以我一直在努力解决这个问题。我正在尝试在Android游戏应用中加载AdMob横幅广告。我按照教程来谚语,我一直得到这个错误:
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/Ads: There was a problem getting an ad response. ErrorCode: 0
W/Ads: Failed to load ad: 0
我已经确认该项目中包含最新版本的Play服务(9.6.0)。我的Firebase是最新的,我在我的gradle中包含了核心,身份验证和广告库。我还在Firebase中定义了身份验证方法。我的代码如下:
public class MainActivity extends BaseGameActivity {
PApplet fragment;
private static final String MAIN_FRAGMENT_TAG = "main_fragment";
private static final int REQUEST_PERMISSIONS = 1;
private AdView adView;
int viewId = 0x1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
FrameLayout frame = new FrameLayout(this);
frame.setId(View.generateViewId());
if (savedInstanceState == null) {
fragment = new box_jump();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(frame.getId(), fragment, MAIN_FRAGMENT_TAG).commit();
} else {
fragment = (PApplet) getFragmentManager().findFragmentByTag(MAIN_FRAGMENT_TAG);
}
MobileAds.initialize(getApplicationContext(), "ca-app-pub-2885131178882767~7287529334");
adView = new AdView(this);
adView.setAdUnitId("ca-app-pub-2885131178882767/3137714538");
adView.setAdSize(AdSize.SMART_BANNER);
RelativeLayout mainLayout = new RelativeLayout(this);
mainLayout.addView(frame);
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
mainLayout.addView(adView, adParams);
setContentView(mainLayout);
}
public void showAd() {
adView.setVisibility(View.VISIBLE);
adView.loadAd(new AdRequest.Builder().addTestDevice("4B8A8368A73BDA47066700EA90CB50DB").build());
}
public void hideAd() {
adView.setVisibility(View.GONE);
}
}
我非常感谢所有帮助,并且很乐意验证您可能需要的任何信息。
答案 0 :(得分:0)