I have created an application in android studio and it works fine but when you put the ad theme with admob it can not even be opened and it comes out all the time the application has stopped working. I have followed guides, tutorials, etc.
I have created a new project in android studio with the admob activity selecting ad in banner to test without entering any code if it works and the same error comes out, here I leave the code:
ALL UPDATED
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- 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" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
MainActivity.java package com.example.ruben.safewin;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
EditText editText4, editText5, editText6;
Button button;
TextView textView4;
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, getResources().getString(R.string.banner_ad_unit_id));
// Load an ad into the AdMob banner view.
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//Use your own Test Device Id, from LogCat : Use AdRequest.Builder.addTestDevice("xxxxxxxxxxxx") to get test ads on this device.
.addTestDevice("821F6B84B97F82FBEBE855AD542340A4")
.build();
mAdView.loadAd(adRequest);
// Toasts the test ad message on the screen. Remove this after defining your own ad unit ID.
//Toast.makeText(this, TOAST_TEXT, Toast.LENGTH_LONG).show();
editText4 = (EditText) findViewById(R.id.editText4);
editText5 = (EditText) findViewById(R.id.editText5);
editText6 = (EditText) findViewById(R.id.editText6);
textView4 = (TextView) findViewById(R.id.textView4);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(this);
}
public void onClick(View v) {
float num1, num2, porcentaje = 0;
float stake, stake1, stake2 = 0;
AlertDialog.Builder dialogo = new AlertDialog.Builder(this);
dialogo.setMessage("Los campos no pueden estar vacíos");
dialogo.setTitle("Error");
dialogo.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog dialog=dialogo.create();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(button.getWindowToken(), 0);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
strings.xml
<resources>
<string name="app_name">SafeWin</string>
<string name="action_settings">Settings</string>
<!-- -
This is an ad unit ID for a banner test ad. Replace with your own banner ad unit id.
For more information, see https://support.google.com/admob/answer/3052638
<!- -->
<string name="banner_ad_unit_id">ca-app-pub-3748175831230810/7065359892</string>
This is all, I do not know if maybe something is missing when copying and pasting, I hope an answer, thank you.
Here I leave the logcat:
2018-10-20 11: 24: 59.561 1510-2134 /? E / ANDR-PERF-JNI: com_qualcomm_qtiperformance_native_perf_io_prefetch_start
2018-10-20 11: 24: 59.562 563-3291 /? E / msm8916_platform: platform_check_backends_match: Invalid snd_device =
2018-10-20 11: 24: 59.562 563-3291 /? E / audio_hw_primary: start_dsm_feedback_process: pcm device id 43
2018-10-20 11: 24: 59.564 1510-2134 /? E / ActivityTrigger: activityStartTrigger: not whiteListedcom.example.ruben.safewin / com.example.ruben.safewin.MainActivity / 1
2018-10-20 11: 24: 59.566 1510-2134 /? E / ActivityTrigger: activityResumeTrigger: not whiteListedcom.example.ruben.safewin / com.example.ruben.safewin.MainActivity / 1
2018-10-20 11: 24: 59.571 1510-2134 /? E / ActivityTrigger: activityResumeTrigger: not whiteListedcom.example.ruben.safewin / com.example.ruben.safewin.MainActivity / 1
2018-10-20 11: 24: 59.581 563-3291 /? E / msm8916_platform: platform_get_snd_device_backend_index: no hw_interface set for device speaker
2018-10-20 11: 24: 59.581 563-3291 /? E / audio_hw_utils: send_app_type_cfg_for_device: Could not get the backend index for snd device speaker ret = -22
2018-10-20 11: 25: 00.649 27391-27419 / com.example.ruben.safewin E / cr_VariationsUtils: Failed reading seed file "/data/user/0/com.example.ruben.safewin/app_webview/ variations_seed_new ": /data/user/0/com.example.ruben.safewin/app_webview/variations_seed_new (No such file or directory)
2018-10-20 11: 25: 00.690 27423-27423 /? E // system / bin / webview_zygote32: Failed to make and chown / acct / uid_99524: Permission denied
2018-10-20 11: 25: 00.690 27423-27423 /? E / Zygote: createProcessGroup (99524, 0) failed: Permission denied
2018-10-20 11: 25: 00.760 27453-27453 /? E / asset: setgid: Operation not permitted
2018-10-20 11: 25: 01.228 1510-1630 /? E / ANDR-PERF-JNI: com_qualcomm_qtiperformance_native_perf_io_prefetch_start
2018-10-20 11: 25: 23.934 1510-1600 /? E / BatteryExternalStatsWorker: no controller energy info supplied for bluetooth