我尝试在我的Android应用中实施Google AdMob广告(我正在使用IntelliJ Idea)。为此,我主要遵循本教程:https://developers.google.com/admob/android/eclipse
为了安装Google Play服务,我按照此主题的第二个答案:Importing google-play-services lib into Intellij IDEA 12 (and 13)
但是当我运行应用程序时,我得到以下异常:http://pastebin.com/6Dna69w4
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathestar.nocontrol"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
MainActivity:
public class MainActivity extends Activity{
public static SharedPreferences prefs;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
prefs = getPreferences(Context.MODE_PRIVATE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
@Override
protected void onPause(){
((AdView) findViewById(R.id.adView)).pause();
MainView.instance.musicPlayer.pause();
MainView.instance.goToMenu();
super.onPause();
}
@Override
protected void onResume(){
((AdView) findViewById(R.id.adView)).resume();
super.onResume();
MainView.instance.musicPlayer.start();
}
@Override
public void onBackPressed(){
MainView.instance.goBack();
}
@Override
public void onDestroy() {
((AdView) findViewById(R.id.adView)).destroy();
super.onDestroy();
}
}
我的项目显然不包含build.gradle文件。
如果您需要更多信息,请告诉我。
提前致谢!
答案 0 :(得分:0)
好的,我现在只需加载一个备份并重新完成整个工作就可以了。