Кратко суть дела: запускаю приложение (игру) на реальном устройстве (телефоне, планшете) - все хорошо. На эмуляторе телефона - все хорошо, а вот на эмуляторе планшета 7 или 10.1 (эмулирую API8 и выше - без разницы) приложение не запускается и вылетает с ошибкой (об этом ниже).
Подумал, что это глюки эмулятора и выложил приложение на GooglePlay.
Несколько дней все было Ок, но вот сегодня увидел в консоли разработчика сбой (ANR) и лог ошибки такой же как был на эмуляторе планшетов при вылете приложения.
Поиск по Stack Overflow приводит к очен похожим багам, но до сути проблемы никто не дошел
(только в одном ответе есть совет установить в манифесте атрибут <style name="MyTheme" parent="android:Theme"> но у меня этот атрибут установлен и все-равно ошибка появляется)
Вот лог ошибки:
java.lang.RuntimeException: Unable to start activity ComponentInfo{тут_название_моего_пакета.GameActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
at android.app.Activity.setContentView(Activity.java:1657)
at тут_название_моего_пакета.GameActivity.onCreate(GameActivity.java:65)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000a a=-1 r=0x7f02000a}
at android.content.res.Resources.loadDrawable(Resources.java:1681)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1951)
at android.view.View.<init>(View.java:1899)
at android.view.ViewGroup.<init>(ViewGroup.java:286)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
... 24 more
Вот разметка xml файла (game_layout), которая грузится в GameActivity в методе onCreate:
Код: Выделить всё
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/cloud_for_game_layout">
<RelativeLayout
android:id="@+id/game_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@+id/game_ads_layout">
<TextView
android:id="@+id/game_dif_title_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="@string/game_dif_title_text"
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_dif_title_text_color"/>
<TextView
android:id="@+id/game_player_name_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/settings_player_name_text"
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_player_name_color"/>
<TextView
android:id="@+id/game_score_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:text="@string/game_score_title_text"
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_score_title_text_color" />
<TextView
android:id="@+id/game_dif_title_value_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_below="@+id/game_dif_title_text_id"
android:layout_alignParentLeft="true"
android:textColor="@color/game_dif_value_text_color"
android:textSize="@dimen/game_title_text_size" />
<ImageButton
android:id="@+id/game_reload_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/reload_but_state"
android:layout_alignParentLeft="true"
android:layout_below="@+id/game_dif_title_value_id"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<ImageView
android:id="@+id/game_relaxcard_image_id"
android:layout_width="@dimen/game_medal_size"
android:layout_height="@dimen/game_medal_size"
android:src="@drawable/relax_card"
android:layout_toLeftOf="@+id/game_medal1_image_id"
android:layout_below="@+id/game_player_name_text_id"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<ImageView
android:id="@+id/game_medal1_image_id"
android:layout_width="@dimen/game_medal_size"
android:layout_height="@dimen/game_medal_size"
android:src="@drawable/bronzmedal"
android:layout_toLeftOf="@+id/game_null_text_id"
android:layout_below="@+id/game_player_name_text_id"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<TextView
android:id="@+id/game_null_text_id"
android:layout_width="0dp"
android:layout_height="0dp"
android:textIsSelectable="false"
android:layout_below="@+id/game_player_name_text_id"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/game_medal2_image_id"
android:layout_width="@dimen/game_medal_size"
android:layout_height="@dimen/game_medal_size"
android:src="@drawable/silvermedal"
android:layout_toRightOf="@+id/game_null_text_id"
android:layout_below="@+id/game_player_name_text_id"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<ImageView
android:id="@+id/game_medal3_image_id"
android:layout_width="@dimen/game_medal_size"
android:layout_height="@dimen/game_medal_size"
android:src="@drawable/goldmedal"
android:layout_toRightOf="@+id/game_medal2_image_id"
android:layout_below="@+id/game_player_name_text_id"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<TextView
android:id="@+id/game_score_value_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_below="@+id/game_score_text_id"
android:layout_alignParentRight="true"
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_score_value_text_color"/>
<TextView
android:id="@+id/game_pause_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_below="@+id/game_time_title_text_id"
android:layout_centerHorizontal="true"
android:textColor="@color/game_pause_text_color"
android:textSize="@dimen/game_title_text_size" />
<TextView
android:id="@+id/game_time_title_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_below="@+id/game_score_value_id"
android:layout_alignParentRight="true"
android:text="@string/game_timer_title_text"
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_time_title_text_color" />
<TextView
android:id="@+id/game_time_value_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/game_margin"
android:textIsSelectable="false"
android:layout_below="@+id/game_time_title_text_id"
android:layout_alignParentRight="true"
android:text=""
android:textSize="@dimen/game_title_text_size"
android:textColor="@color/game_time_value_text_color" />
<GridView
android:id="@+id/game_GameField_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="6"
android:stretchMode="spacingWidth"
android:columnWidth="@dimen/game_grid_colwidth"
android:verticalSpacing="@dimen/game_grid_vertspace"
android:horizontalSpacing="@dimen/game_grid_horspace"
android:layout_above="@+id/game_general_image_id"
android:layout_below="@+id/game_time_value_id"
android:layout_centerHorizontal="true" />
<ImageButton
android:id="@+id/game_backToMenu_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/back_but_state"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<ImageButton
android:id="@+id/game_Pause_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_toRightOf="@+id/game_backToMenu_id"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<TextView
android:id="@+id/game_general_image_id"
android:layout_width="@dimen/game_general_image_size"
android:layout_height="@dimen/game_general_image_size"
android:textIsSelectable="false"
android:background="@drawable/general_image"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"
android:textSize="@dimen/game_general_image_text_size"/>
<ImageButton
android:id="@+id/game_Help_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/help_but_state"
android:layout_toLeftOf="@+id/game_Sound_id"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
<ImageButton
android:id="@+id/game_Sound_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/game_margin"
android:contentDescription="@string/game_image_description_text"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/game_ads_layout"
android:layout_width="320dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="@string/admob_publisher_id"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
</RelativeLayout>Код: Выделить всё
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"Файл манифеста:
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
package="имя_моего_пакета"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait"
android:name="имя_моего_пакета.MenuActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait"
android:name="имя_моего_пакета.HelpActivity"
android:label="@string/app_name" >
</activity>
<activity
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait"
android:name="имя_моего_пакета.SettingsActivity"
android:label="@string/app_name" >
</activity>
<activity
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait"
android:name="имя_моего_пакета.GameActivity"
android:label="@string/app_name" >
</activity>
<activity
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait"
android:name="имя_моего_пакета.BonusesActivity"
android:label="@string/app_name" >
</activity>
<activity
android:screenOrientation="portrait"
android:name="имя_моего_пакета.RelaxActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>Код: Выделить всё
android:windowSoftInputMode=Конечно я делал клин проекта, но ошибка остается.
Подскажите в чем проблема? куда копать? Кто сталкивался с подобным?
Update: сейчас опять запустил на эмуляторе, все тоже самое, только с разницей что ругается на другую активити (MenuActivity - она грузится по умолчанию и в ней кроме 4 кнопок ничего нет!) и опять ошибка:
android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout