0

I tried to implement Google AdMob ads in my Android app (I am using IntelliJ Idea). For this I mostly followed this tutorial: https://developers.google.com/admob/android/eclipse

For installing Google Play Services I followed the second answer on this thread: Importing google-play-services lib into Intellij IDEA 12 (and 13)

But when I run the app I get the following Exception: 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();
}

}

My project apparently doesn't contain a build.gradle file.

If you need more information, please tell me.

Thanks in advance!

Community
  • 1
  • 1
arch1t3cht30
  • 243
  • 1
  • 2
  • 14

1 Answers1

0

Ok, I got it to work now by just loading a backup and doing the whole thing again

arch1t3cht30
  • 243
  • 1
  • 2
  • 14