应用程序在更改min sdk版本和目标版本时崩溃

时间:2013-12-24 09:49:09

标签: android xml performance android-layout android-view

我有这个应用程序在我的测试手机上工作,但我在三星手机中遇到了解析包错误。

进一步的谷歌搜索给了我解决方案将sdk版本更改为1.我将min sdk版本更改为1(最初为13)并将android目标更改为1(最初为13),并且我的应用程序崩溃,可以帮助一些人我就这个。

这是eclipse logcat

 E/AndroidRuntime(10146): FATAL EXCEPTION: main
 E/AndroidRuntime(10146): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mystictreegames.pagecurl/com.mystictreegames.pagecurl.StandaloneExample}: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystictreegames.pagecurl.PageCurlView
 E/AndroidRuntime(10146):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
 E/AndroidRuntime(10146):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
 E/AndroidRuntime(10146):   at android.app.ActivityThread.access$600(ActivityThread.java:162)
 E/AndroidRuntime(10146):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
 E/AndroidRuntime(10146):   at android.os.Handler.dispatchMessage(Handler.java:107)
 E/AndroidRuntime(10146):   at android.os.Looper.loop(Looper.java:194)
 E/AndroidRuntime(10146):   at android.app.ActivityThread.main(ActivityThread.java:5371)
 E/AndroidRuntime(10146):   at java.lang.reflect.Method.invokeNative(Native Method)
 E/AndroidRuntime(10146):   at java.lang.reflect.Method.invoke(Method.java:525)
 E/AndroidRuntime(10146):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
 E/AndroidRuntime(10146):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
 E/AndroidRuntime(10146):   at dalvik.system.NativeStart.main(Native Method)
 E/AndroidRuntime(10146): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystictreegames.pagecurl.PageCurlView
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.createView(LayoutInflater.java:613)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
 E/AndroidRuntime(10146):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281)
 E/AndroidRuntime(10146):   at android.app.Activity.setContentView(Activity.java:1881)
 E/AndroidRuntime(10146):   at com.mystictreegames.pagecurl.StandaloneExample.onCreate(StandaloneExample.java:22)
 E/AndroidRuntime(10146):   at android.app.Activity.performCreate(Activity.java:5122)
 E/AndroidRuntime(10146):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
 E/AndroidRuntime(10146):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
 E/AndroidRuntime(10146):   ... 11 more
 E/AndroidRuntime(10146): Caused by: java.lang.reflect.InvocationTargetException
 E/AndroidRuntime(10146):   at java.lang.reflect.Constructor.constructNative(Native Method)
 E/AndroidRuntime(10146):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
 E/AndroidRuntime(10146):   at android.view.LayoutInflater.createView(LayoutInflater.java:587)
 E/AndroidRuntime(10146):   ... 22 more
 E/AndroidRuntime(10146): Caused by: java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
 E/AndroidRuntime(10146):   at android.graphics.Bitmap.createBitmap(Bitmap.java:554)
 E/AndroidRuntime(10146):   at com.mystictreegames.pagecurl.PageCurlView.init(PageCurlView.java:419)
 E/AndroidRuntime(10146):   at com.mystictreegames.pagecurl.PageCurlView.<init>(PageCurlView.java:208)
 E/AndroidRuntime(10146):   ... 25 more

1 个答案:

答案 0 :(得分:0)

不要将目标SDK版本设置为1.将其设置为您的实际目标:您开发和测试应用程序的级别。

当您将目标设置为小于4时,您将启用兼容模式,该模式会自动扩展资源,假设所有内容都是MDPI(reference)。此自动缩放可能是异常java.lang.IllegalArgumentException: x + width must be <= bitmap.width()的原因。