So I recently uploaded my app to the play store and i wanted to implement ads, so I looked up this tutorial and It said I needed the AdMob library, so I went looking for it on the AdMob sites where they say I can get it with the google play service SDK which is great since I can download it with processing
I use the code that is used in the forum post which is this one:
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.RelativeLayout;
import com.google.ads.*;
@ Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
RelativeLayout adsLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
// Displays Ads at the bottom of your sketch, use Gravity.TOP to display them at the top
adsLayout.setGravity(Gravity.BOTTOM);
AdView adView = new AdView(this, AdSize.BANNER, "your-publisher-id"); // add your app-id
adsLayout.addView(adView);
AdRequest newAdReq = new AdRequest();
// Remark: uncomment next line for testing your Ads (fake ads)
//newAdReq.setTesting(true);
adView.loadAd(newAdReq);
window.addContentView(adsLayout,lp2);
}
but now the problem is that I got an error that says this:
The import com.google cannot be resolved
and the console says this:
----------
1. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 9)
import android.content.pm.PackageManager;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import android.content.pm.PackageManager is never used
----------
2. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 11)
import android.support.v4.content.ContextCompat;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import android.support.v4.content.ContextCompat is never used
----------
3. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 13)
import android.app.AlertDialog;
^^^^^^^^^^^^^^^^^^^^^^^
The import android.app.AlertDialog is never used
----------
4. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 14)
import android.content.DialogInterface;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import android.content.DialogInterface is never used
----------
5. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 15)
import android.Manifest;
^^^^^^^^^^^^^^^^
The import android.Manifest is never used
----------
6. WARNING in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\MainActivity.java (at line 49)
int check;
^^^^^
The value of the local variable check is not used
----------
----------
7. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 13)
import com.google.ads.*;
^^^^^^^^^^
The import com.google cannot be resolved
----------
8. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 14)
import com.google.android.gms.ads.AdRequest;
^^^^^^^^^^
The import com.google cannot be resolved
----------
9. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 15)
import com.google.android.gms.ads.AdView;
^^^^^^^^^^
The import com.google cannot be resolved
----------
10. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 16)
import com.google.android.gms.ads.AdSize;
^^^^^^^^^^
The import com.google cannot be resolved
----------
11. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 17)
import com.google.android.gms.ads.MobileAds;
^^^^^^^^^^
The import com.google cannot be resolved
----------
12. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 60)
AdView adView = new AdView(this.getActivity());
^^^^^^
AdView cannot be resolved to a type
----------
13. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 60)
AdView adView = new AdView(this.getActivity());
^^^^^^
AdView cannot be resolved to a type
----------
14. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 61)
adView.setAdSize(AdSize.BANNER);
^^^^^^
AdSize cannot be resolved to a variable
----------
15. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 64)
AdRequest newAdReq = new AdRequest.Builder()
^^^^^^^^^
AdRequest cannot be resolved to a type
----------
16. ERROR in C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\src\processing\test\sketch_170817a\sketch_170817a.java (at line 64)
AdRequest newAdReq = new AdRequest.Builder()
^^^^^^^^^
AdRequest cannot be resolved to a type
----------
16 problems (10 errors, 6 warnings)
BUILD FAILED
C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\build.xml:15: The following error occurred while executing this line:
C:\Users\sjors\AppData\Local\Temp\android7328373206848409503sketch\build.xml:28: Compile failed; see the compiler error output for details.
What did I do wrong I installed the google play service SDK through the default SDK manager.