MWP MWP - 1 year ago 77
Android Question

(android)Cant start activity => java.lang.RuntimeException: Unable to start activity ComponentInfo

Im developing an android application. But, i have one problem..
Whenever i run my app through Bluestacks, or Android emulator, i have an such error. It works on my actual phone.

java.lang.RuntimeException: Unable to start activity ComponentInfo{semo.msoft.yusearch/semo.msoft.yusearch.LoginActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>


it occured in this line

setContentView(R.layout.activity_login);


I have No Idea about this..
please help

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="semo.msoft.yusearch">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">
<activity
android:name=".LoginActivity"
android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/Theme.Transparent" />
<activity
android:name=".FindActivity"
android:theme="@style/Theme.YU" />
<activity
android:name=".TimeActivity"
android:theme="@style/Theme.YU" />
<activity
android:name=".LectureActivity"
android:theme="@style/Theme.YU" />
<activity
android:name=".SplashActivity"
android:noHistory="true"
android:theme="@style/Theme.Transparent" />
<activity
android:name=".ScoreActivity"
android:theme="@style/Theme.YU" />
<activity android:name=".MapActivity"
android:theme="@style/Theme.YU"></activity>
</application>

</manifest>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/login_background"
android:orientation="vertical"
tools:context="semo.msoft.yusearch.LoginActivity">


<TextView
android:layout_marginTop="210dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:text="Member Login"
android:textColor="#579ce1"/>

<LinearLayout
android:layout_marginTop="8dp"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@drawable/round_background"
android:layout_gravity="center"
android:orientation="horizontal">

<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/icon_id"/>


<EditText
android:layout_width="200dp"
android:layout_height="40dp"
android:inputType="number"
android:ems="10"
android:id="@+id/id"
android:paddingLeft="10dp"
android:hint="학번을 입력하세요."
android:textColorHint="#b6b1b1"
android:background="#ffffff"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_gravity="center_horizontal" />

</LinearLayout>



<LinearLayout
android:layout_marginTop="8dp"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@drawable/round_background"
android:layout_gravity="center"
android:orientation="horizontal">

<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/pw"/>


<EditText
android:layout_width="200dp"
android:layout_height="40dp"
android:inputType="textPassword"
android:ems="20"

android:id="@+id/pw"
android:paddingLeft="10dp"
android:hint="비밀번호를 입력하세요."
android:textColorHint="#b6b1b1"
android:textSize="15sp"
android:textColor="@android:color/black"
android:background="#ffffff"
android:layout_gravity="center_horizontal" />

</LinearLayout>

<Button
android:layout_width="300dp"
android:layout_height="40dp"
android:id="@+id/login"
android:textColor="#ffffff"
android:textStyle="bold"
android:text="로그인"
android:background="@drawable/rounc_login"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal"/>

</LinearLayout>

MWP MWP
Answer Source

I solved it. If drawable resources are located V21 folder, it can't make an error under some specific version of device. Just put Drawable resource to Drawable Folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download