errors in adding Admod in android studio in the layout file



I have this app, which was started from blank activity, unlike in the tutorial I am reading: https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start


**1.**Is there a problem if I just started with the blank activity?


like in the tutorial, I added this peace of code to the build.gradle:



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:6.+'
}


Then, in the Manifest, I added this peaces of code:



<!-- Include required permissions for Google Mobile Ads to run-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<!--This meta-data tag is required to use Google Play Services.-->
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />


Until now there are no problems. I created the "fragment_ad" in the layout folder, and replaced the default code with this(Like said in the tutorial):



<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

</RelativeLayout>


...


In the tutorial, in step two(Create the AdFragment class), I noticed that I should have a PlaceHolderFragment class in my MainClass, so I pasted this code(Created another project, this time with blank activity and Fragment", went to the java file, and copied the clas below):



public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_ad, container, false);
return rootView;
}
}


The next step is to go to the main activity layout, pasted the fragments below:



<fragment
android:id="@+id/adFragment"
android:name="com.google.android.gms.example.bannerexample.MainActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />


**2.**And here is the problem, i pasted those fragments and an error appears: "Cannot resolve symbol 'example'", on both of the "android:name="com.goo..."


Thanks for the help(There is still one more step after this problem is solved);


No comments:

Post a Comment