Android的支持库动作条上的NullPointerException版本2.2(8级) - 用preferences.xml冲突 [英] Android Support Library ActionBar NullPointerException on version 2.2 (level 8) - conflict with preferences.xml
问题描述
我使用的是V7支持库,以显示在Android 2.X的动作条。
I am using the v7 Support Library to show an ActionBar on Android 2.x.
当我部署的应用程序的设备在我的IDE(IntelliJ IDEA的)应用程序工作正常。
When I deploy the app to the device in my IDE (Intellij IDEA) the app works fine.
当我构建和打包部署到使用maven Play商店应用程序,我发现我出现以下情况例外,当我安装我的设备和应用程序崩溃上运行的打包应用程序。 (它没有在V8模拟器太)。它在Android V4.3两种情况下正常工作。
When I build and package the app to be deployed to the Play Store using maven, I find that I get the following exception when I install and run the packaged app on my device and the app crashes. (It fails on the v8 simulator too). It works fine in both scenarios on android v4.3.
任何想法,为什么当使用Maven构建这会崩溃?
Any idea why this would be crashing when built with maven?
01-07 15:05:22.671 937-937/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.triopsis.as.mobile.android/com.triopsis.as.mobile.android.activity.MainMenuActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:677)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
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:198)
at android.app.Activity.setContentView(Activity.java:1647)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:180)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:134)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
at com.triopsis.as.mobile.android.activity.MainMenuActivity.onCreate(MainMenuActivity.java:43)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at android.support.v7.internal.widget.ActionBarView.<init>(ActionBarView.java:218)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:677)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
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:198)
at android.app.Activity.setContentView(Activity.java:1647)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:180)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:134)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
at com.triopsis.as.mobile.android.activity.MainMenuActivity.onCreate(MainMenuActivity.java:43)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v7.internal.widget.ActionBarView$HomeView.onFinishInflate(ActionBarView.java:1301)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.support.v7.internal.widget.ActionBarView.<init>(ActionBarView.java:218)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:677)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
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:198)
at android.app.Activity.setContentView(Activity.java:1647)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:180)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:134)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
at com.triopsis.as.mobile.android.activity.MainMenuActivity.onCreate(MainMenuActivity.java:43)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
我有以下的依赖关系Maven的:
I have the following dependencies in maven:
<dependencies>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.0_r3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.0.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v13</artifactId>
<version>19.0.1</version>
<type>jar</type>
</dependency>
</dependencies>
和以下Maven的Android的插件配置:
and the following maven-android-plugin configured:
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<sdk>
<platform>14</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
更新
它采取了一段时间,但我发现,当我有RES / XML / preferences.xml以preferenceScreen设置文件,那么它会导致此崩溃。如果我删除这个文件,那么它不会崩溃。
任何人都知道为什么,可能会导致这个问题?
It has taken a while, but I have discovered that when I have the res/xml/preferences.xml file with PreferenceScreen settings then it causes this crash. If I remove this file, then it does not crash. Anyone know why that could cause this issue?
推荐答案
你abslutely需要的功能Android的Maven的插件
版本 3.8。 2
?这似乎是bugy。
Do you abslutely need features of android-maven-plugin
version 3.8.2
? It seems to be bugy.
有一个类似的问题出现在我们的项目更新后的 Android的Maven的插件
从版本 3.8.0
到 3.8.2
。
A similar problem appeared in our project after updating android-maven-plugin
from version 3.8.0
to 3.8.2
.
回落至版本 3.8.0
解决了这个问题。
Falling back to version 3.8.0
solved the problem.
症状:结果
我们的结论是,问题是在apklib的链接,所有ressources引用(版式,图形...)似乎disaligned。例如,一个布局或绘制在显示,而不是其他。在布局访问缺少一个参考/ ID时,应用程序崩溃(参考并不present因为错误的布局加载)。
Symptoms:
Our conclusion is that the problem was in the linking of the apklib, all ressources (layouts, drawables...) referenced seemed to be disaligned. For example a layout or a drawable was displayed instead of another. Application was crashing when accessing to a missing reference/id in a layout (the reference was not present because the wrong layout was loaded).
请参阅问题的http:// code.google.com / p / Maven的Android平台的插件/问题/细节?ID = 441
这篇关于Android的支持库动作条上的NullPointerException版本2.2(8级) - 用preferences.xml冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!