This problem arises when I start the app. This is returned to me by Google Play because testing it in my emulator and cell phone does not cause problems.
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2257)
at android.app.ActivityThread.access$800 (ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1210)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601)
at dalvik.system.NativeStart.main (Native Method)
Caused by: android.view.InflateException:
at android.view.LayoutInflater.createView (LayoutInflater.java:620)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView (LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:694)
at android.view.LayoutInflater.inflate (LayoutInflater.java:469)
at android.view.LayoutInflater.inflate (LayoutInflater.java:397)
at android.view.LayoutInflater.inflate (LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:139)
at com.yamil.sirenadepolicia.MainActivity.onCreate (MainActivity.java:27)
at android.app.Activity.performCreate (Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2162)
Tonight I put the activitymain and manifest
XML Activity Main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/fondodos"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:textSize="40sp"
android:textColor="@android:color/background_light"
android:text="@string/inicio" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/background_light"
android:text="@string/iniciodos" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/boton_policia"
android:padding="20dp"
android:text="@string/policia"
android:gravity="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/boton_sirenas"
android:padding="20dp"
android:text="@string/sirenas"
android:gravity="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pistola"
android:padding="20dp"
android:text="@string/pistola"
android:gravity="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3104204509358318/2502427265" />
</LinearLayout>
</LinearLayout>
Activity Main
package com.yamil.sirenadepolicia;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
public class MainActivity extends AppCompatActivity {
public Button policia,sirenas,pistola; //Creacion de botones
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//FullScreen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//FullScreen
//PUBLICIDAD
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3104204509358318/9522706159");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Load the next interstitial.
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
});
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
//PUBLICIDAD
//REFERENCIAS
policia = (Button) findViewById(R.id.boton_policia);
sirenas = (Button) findViewById(R.id.boton_sirenas);
pistola =(Button)findViewById(R.id.pistola);
//FIN REFERENCIAS
//BOTONES
policia.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent a = new Intent(MainActivity.this, policia.class);
startActivity(a);
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
});
sirenas.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent b = new Intent(MainActivity.this, sirenas.class);
startActivity(b);
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
});
pistola.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent c=new Intent(MainActivity.this,pistola.class);
startActivity(c);
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
});
//FIN DE BOTONES
}
}
Build
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId 'com.yamil.sirenadepolicia'
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services:11.0.4'
testCompile 'junit:junit:4.12'
}
Try to look for some error in the xml file and I have not found anything. I would appreciate the help.
This is another one of the errors
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2257)
at android.app.ActivityThread.access$800 (ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1210)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601)
at dalvik.system.NativeStart.main (Native Method)
Caused by: java.lang.NullPointerException:
at com.yamil.sirenadepolicia.MainActivity.onCreate (MainActivity.java:47)
at android.app.Activity.performCreate (Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2162)