我刚刚推出的Play商店名称印度徽标测验了java.lang.RuntimeException:无法启动活动
而且我收到了一定的崩溃报告我的第一个Android应用程序。其中一个是这样的:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.indian.logoquiz/com.indian.logoquiz.Play}:
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.access$700(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java: 56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
at android.view.LayoutInflater.inflate(LayoutInflater.java:467)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
at android.app.Activity.setContentView(Activity.java:1928)
at com.indian.logoquiz.Play.onCreate(Play.java:39)
at android.app.Activity.performCreate(Activity.java:5250)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
... 23 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
at android.content.res.Resources.loadDrawable(Resources.java:2854)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3460)
at android.view.ViewGroup.<init>(ViewGroup.java:446)
at android.widget.LinearLayout.<init>(LinearLayout.java:176)
at android.widget.LinearLayout.<init>(LinearLayout.java:172)
... 26 more
我play.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/playpage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<Button
android:id="@+id/lvl1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text=""
/>
<Button
android:id="@+id/lvl2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text=""
/>
<Button
android:id="@+id/lvl3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" >
<Button
android:id="@+id/lvl4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/lvl7"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl8"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:alpha="0.85"
android:text="" />
<Button
android:id="@+id/lvl9"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.34"
android:alpha="0.85"
android:text="" />
</LinearLayout>
</LinearLayout>
的应用是越来越上按等级1按钮坠毁.... 难道是因为在任何情况下嵌套的重量?? 请帮助!...
我正在使用的代码: 可以通过回收位图做的一种方式 公共位图getBitmap(上下文CTX,字符串pathNameRelativeToAssetsFolder) \t { \t \t的InputStream bitmapIs = NULL; \t \t Bitmap bmp = null; \t \t尝试 \t \t { \t \t \t bitmapIs = ctx.getAssets()。开(pathNameRelativeToAssetsFolder); \t \t bmp = BitmapFactory.decodeStream(bitmapIs); \t \t \t } \t \t 捕\t(IOException的E) \t \t { \t \t e.printStackTrace(); \t \t} \t \t最后 \t \t { \t \t如果(bitmapIs!= NULL) \t \t { \t \t \t尝试 \t \t \t { \t \t \t \t \t bitmapIs.close(); \t \t \t \t \t \t \t \t \t} \t \t \t赶上(IOException的E) \t \t \t \t { \t \t \t \t \t // TODO自动生成的catch程序块 \t \t \t \t \t e.printStackTrace ( ); \t \t \t \t} \t \t} \t \t} \t \t返回BMP; \t} – Vaido
因为我已将所有图像保存在我的资产文件夹中! – Vaido
但只要logcat值得关注,位图中只有内存异常。所以最好检查一下哪种情况会出错? –