我有一个带有鳍状肢的应用程序和Flipper每页上的图像动画...... 应用程序适用于HTC Desire,Desire S,三星Galaxy tab 1(7')......但是当我尝试在三星Galaxy Tab 10.1上运行时 - 出现此错误......
flipper = (ViewFlipper) findViewById(R.id.flipper);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int layouts[] = new int[]{ R.layout.first, R.layout.second, R.layout.third, R.layout.fourth,
R.layout.fifth, R.layout.sixth, R.layout.seventh, R.layout.eighth, R.layout.nineth, R.layout.tenth,
R.layout.eleventh, R.layout.twelveth, R.layout.thirteen, R.layout.fourteenth };
for (int layout : layouts)
flipper.addView(inflater.inflate(layout, null));
02-16 09:33:44.129: E/AndroidRuntime(1733): FATAL EXCEPTION: main
02-16 09:33:44.129: E/AndroidRuntime(1733): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.home/com.home.Main}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1751)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.os.Handler.dispatchMessage(Handler.java:99)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.os.Looper.loop(Looper.java:132)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread.main(ActivityThread.java:4028)
02-16 09:33:44.129: E/AndroidRuntime(1733): at java.lang.reflect.Method.invokeNative(Native Method)
02-16 09:33:44.129: E/AndroidRuntime(1733): at java.lang.reflect.Method.invoke(Method.java:491)
02-16 09:33:44.129: E/AndroidRuntime(1733): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
02-16 09:33:44.129: E/AndroidRuntime(1733): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
02-16 09:33:44.129: E/AndroidRuntime(1733): at dalvik.system.NativeStart.main(Native Method)
02-16 09:33:44.129: E/AndroidRuntime(1733): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.createView(LayoutInflater.java:596)
02-16 09:33:44.129: E/AndroidRuntime(1733): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.inflate(LayoutInflater.java:457)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
02-16 09:33:44.129: E/AndroidRuntime(1733): at com.home.Main.onCreate(Main.java:98)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
02-16 09:33:44.129: E/AndroidRuntime(1733): ... 11 more
02-16 09:33:44.129: E/AndroidRuntime(1733): Caused by: java.lang.reflect.InvocationTargetException
02-16 09:33:44.129: E/AndroidRuntime(1733): at java.lang.reflect.Constructor.constructNative(Native Method)
02-16 09:33:44.129: E/AndroidRuntime(1733): at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.LayoutInflater.createView(LayoutInflater.java:576)
02-16 09:33:44.129: E/AndroidRuntime(1733): ... 20 more
02-16 09:33:44.129: E/AndroidRuntime(1733): Caused by: java.lang.OutOfMemoryError
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:577)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.content.res.Resources.loadDrawable(Resources.java:1869)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.View.<init>(View.java:2462)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.View.<init>(View.java:2401)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.ViewGroup.<init>(ViewGroup.java:359)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
02-16 09:33:44.129: E/AndroidRuntime(1733): ... 23 more
据我所知,谷歌搜索此错误是因为Manifest,任何想法?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.home"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name"
android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
答案 0 :(得分:1)
不,这是因为OutOfMemoryError
例外。您正在尝试从资源中加载足够重的位图:
02-16 09:33:44.129: E/AndroidRuntime(1733): Caused by: java.lang.OutOfMemoryError
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:577)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.content.res.Resources.loadDrawable(Resources.java:1869)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.View.<init>(View.java:2462)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.View.<init>(View.java:2401)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.view.ViewGroup.<init>(ViewGroup.java:359)
02-16 09:33:44.129: E/AndroidRuntime(1733): at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
02-16 09:33:44.129: E/AndroidRuntime(1733): ... 23 more