java - Inflate Exception caused by setContentView of Activity in android -
i have made game in android studio.it working fine in emulators , own phone. when uploaded play store, got crash report htc m8(running on android 6 marshmallow) of inflate exception setcontentview of activity. provide crash report play store , codes.
mainactivity.java
import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.graphics.typeface; import android.media.mediaplayer; import android.net.uri; import android.os.bundle; import android.support.annotation.*; import android.view.view; import android.view.window; import android.view.windowmanager; import android.widget.button; import android.widget.textview; import android.widget.toast; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.api.googleapiclient; import com.google.android.gms.drive.drive; import com.google.android.gms.games.games; import com.google.android.gms.games.leaderboard.leaderboard; import com.google.example.games.basegameutils.basegameactivity; import com.google.example.games.basegameutils.basegameutils; public class mainactivity extends activity implements googleapiclient.connectioncallbacks, googleapiclient.onconnectionfailedlistener, view.onclicklistener{ mediaplayer btnsound, gamestart; button playa, instructo, high, exitar, googlesignout; private googleapiclient mgoogleapiclient; textview hight; int highsco; public static final string colorbang = "myprefsfile"; private static int rc_sign_in = 9001; private static int rc_unused = 5001; private boolean mresolvingconnectionfailure = false; private boolean mautostartsigninflow = true; private boolean msigninclicked = false; boolean mexplicitsignout = false; boolean minsigninflow = false; int n = 0; /** * attention: auto-generated implement app indexing api. * see https://g.co/appindexing/androidstudio more information. */ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); sharedpreferences prefs = getsharedpreferences(colorbang, mode_private); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_main); mgoogleapiclient = new googleapiclient.builder(this) .addconnectioncallbacks(this) .addonconnectionfailedlistener(this) .addapi(games.api).addscope(games.scope_games) .addapi(drive.api).addscope(drive.scope_appfolder) .build(); btnsound = mediaplayer.create(mainactivity.this, r.raw.buttonclick); gamestart = mediaplayer.create(mainactivity.this, r.raw.splash); findviewbyid(r.id.sign_in_button).setonclicklistener(this); findviewbyid(r.id.full_version).setonclicklistener(this); gamestart.start(); playa = (button) findviewbyid(r.id.bplay); googlesignout = (button) findviewbyid(r.id.sign_out_button); instructo = (button) findviewbyid(r.id.binstructions); high = (button) findviewbyid(r.id.bhighscore); highsco = prefs.getint("chigh", 0); hight = (textview) findviewbyid(r.id.tvhighscoreindicator); exitar = (button) findviewbyid(r.id.bexit); typeface mycustomfont = typeface.createfromasset(getassets(), "fonts/fipps-regular.otf"); playa.settypeface(mycustomfont); hight.settypeface(mycustomfont); instructo.settypeface(mycustomfont); high.settypeface(mycustomfont); exitar.settypeface(mycustomfont); hightime(); googlesignout.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { findviewbyid(r.id.sign_in_button).setvisibility(view.visible); googlesignout.setvisibility(view.gone); signoutclicked(); } }); playa.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { btnsound.start(); intent startplayin = new intent(mainactivity.this, layout.class); startactivity(startplayin); finish(); } }); instructo.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { btnsound.start(); intent instructi = new intent(mainactivity.this, instructions.class); startactivity(instructi); } }); high.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { btnsound.start(); if ( mgoogleapiclient.isconnected()) { startactivityforresult(games.leaderboards.getallleaderboardsintent(mgoogleapiclient),rc_unused); } else{ toast.maketext(mainactivity.this, "please sign in play games account", toast.length_short).show(); } } }); exitar.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { btnsound.start(); toast.maketext(mainactivity.this, "hasta la vista baby", toast.length_short).show(); system.exit(0); finish(); } }); // attention: auto-generated implement app indexing api. // see https://g.co/appindexing/androidstudio more information. } private void hightime() { if (highsco == 0) { hight.setvisibility(view.invisible); } else { hight.settext("your highscore : " + highsco + ""); if (mgoogleapiclient.isconnected()) { games.leaderboards.submitscore(mgoogleapiclient, getstring(r.string.leaderboard_color_score), highsco); } else{ toast.maketext(mainactivity.this,"please sign in ensure leaderboards updates", toast.length_short).show(); } } } @override public void onbackpressed() { if (n == 0) { toast.maketext(mainactivity.this, "press again exit", toast.length_short).show(); n = n + 1; } else { toast.maketext(mainactivity.this, "hasta la vista baby", toast.length_short).show(); system.exit(0); finish(); } } private void gotolink() { uri uri = uri.parse("https://play.google.com/store/apps/details?id=cs.paidversion.arcade.game.colorbang"); intent intent = new intent(intent.action_view, uri); startactivity(intent); } @override protected void onstop() { super.onstop(); mgoogleapiclient.disconnect(); } @override protected void onstart() { super.onstart(); if (!minsigninflow && !mexplicitsignout) { // auto sign in mgoogleapiclient.connect(); } } @override public void onconnected(@nullable bundle bundle) { findviewbyid(r.id.sign_in_button).setvisibility(view.gone); googlesignout.setvisibility(view.visible); if(highsco!=0){ if (mgoogleapiclient.isconnected()) { games.leaderboards.submitscore(mgoogleapiclient, getstring(r.string.leaderboard_color_score), highsco); } } } @override public void onconnectionsuspended(int i) { // attempt reconnect mgoogleapiclient.connect(); } protected void onactivityresult(int requestcode, int resultcode, intent intent) { if (requestcode == rc_sign_in) { msigninclicked = false; mresolvingconnectionfailure = false; if (resultcode == result_ok) { mgoogleapiclient.connect(); } else { // bring error dialog alert user sign-in // failed. r.string.signin_failure should reference error // string in strings.xml file tells user // not signed in, such "unable sign in." basegameutils.showactivityresulterror(this, requestcode, resultcode, r.string.signin_failure); } } } private void signinclicked() { msigninclicked = true; mgoogleapiclient.connect(); } private void signoutclicked() { msigninclicked = false; mexplicitsignout = true; if (mgoogleapiclient != null && mgoogleapiclient.isconnected()) { games.signout(mgoogleapiclient); mgoogleapiclient.disconnect(); } } @override public void onconnectionfailed(@nonnull connectionresult connectionresult) { if (mresolvingconnectionfailure) { // resolving return; } // if sign-in button clicked or if auto sign-in enabled, // launch sign-in flow if (msigninclicked || mautostartsigninflow) { mautostartsigninflow = false; msigninclicked = false; mresolvingconnectionfailure = true; // attempt resolve connection failure using basegameutils. // r.string.signin_other_error value should reference generic // error string in strings.xml file, such "there // issue sign-in, please try again later." if (!basegameutils.resolveconnectionfailure(this, mgoogleapiclient, connectionresult, rc_sign_in, r.string.signin_other_error)) { mresolvingconnectionfailure = false; } } findviewbyid(r.id.sign_in_button).setvisibility(view.visible); googlesignout.setvisibility(view.invisible); } @override public void onclick(view v) { if (v.getid() == r.id.sign_in_button) { signinclicked(); } else if (v.getid() == r.id.full_version) { gotolink(); } } }
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="cs.puzzle.game.paid.colorbangv2.mainactivity" android:background="@drawable/mainback"> <button android:text="play" android:layout_width="260dp" android:gravity="center" android:textsize="20sp" android:layout_height="50dp" android:layout_alignparenttop="true" android:background="@drawable/blackbutton" android:layout_centerhorizontal="true" android:layout_margintop="240dp" android:id="@+id/bplay" /> <button android:text="instructions" android:layout_width="260dp" android:gravity="center" android:textsize="20sp" android:layout_height="50dp" android:layout_below="@id/bplay" android:layout_margintop="20dp" android:background="@drawable/blackbutton" android:layout_centerhorizontal="true" android:id="@+id/binstructions" /> <button android:text="leaderboards" android:layout_width="260dp" android:gravity="center" android:textsize="20sp" android:layout_height="50dp" android:layout_below="@id/binstructions" android:layout_margintop="20dp" android:background="@drawable/blackbutton" android:layout_centerhorizontal="true" android:id="@+id/bhighscore" /> <button android:text="exit" android:layout_width="260dp" android:gravity="center" android:textsize="20sp" android:layout_height="50dp" android:layout_below="@id/bhighscore" android:layout_margintop="20dp" android:background="@drawable/blackbutton" android:layout_centerhorizontal="true" android:id="@+id/bexit" /> <textview android:text="your highscore : xx" android:textsize="15sp" android:textcolor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="75dp" android:id="@+id/tvhighscoreindicator" /> <button android:text="sign out" android:gravity="center" android:textsize="10sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_alignparentend="true" android:background="@drawable/blackbutton" android:drawableleft="@drawable/ic_action_name" android:visibility="gone" android:id="@+id/sign_out_button" /> <com.google.android.gms.common.signinbutton android:id="@+id/sign_in_button" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <button android:text="get full version" android:gravity="center" android:padding="10dp" android:textsize="12sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:background="@drawable/blackbutton" android:id="@+id/full_version" /> </relativelayout>
crash report play store
java.lang.runtimeexception: @ android.app.activitythread.performlaunchactivity (activitythread.java:2423) @ android.app.activitythread.handlelaunchactivity (activitythread.java:2483) @ android.app.activitythread.access$900 (activitythread.java:153) @ android.app.activitythread$h.handlemessage (activitythread.java:1349) @ android.os.handler.dispatchmessage (handler.java:102) @ android.os.looper.loop (looper.java:148) @ android.app.activitythread.main (activitythread.java:5438) @ java.lang.reflect.method.invoke (native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:738) @ com.android.internal.os.zygoteinit.main (zygoteinit.java:628) caused by: android.view.inflateexception: @ android.view.layoutinflater.inflate (layoutinflater.java:543) @ android.view.layoutinflater.inflate (layoutinflater.java:427) @ android.view.layoutinflater.inflate (layoutinflater.java:374) @ com.android.internal.policy.phonewindow.setcontentview (phonewindow.java:393) @ android.app.activity.setcontentview (activity.java:2183) @ cs.puzzle.game.paid.colorbangv2.mainactivity.oncreate (mainactivity.java:62) @ android.app.activity.performcreate (activity.java:6303) @ android.app.instrumentation.callactivityoncreate (instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity (activitythread.java:2376)
Comments
Post a Comment