自Android Lollipop问世以来,我在使用新的Appcompat支持库时无法运行Robolectic测试.我跟着:
我目前的进展如下:https://github.com/fada21/android-tdd-bootstrap
我的配置(蒸馏)是:
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.fada21.android.bootstrap"
minSdkVersion 15
targetSdkVersion 21
Run Code Online (Sandbox Code Playgroud)
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
Run Code Online (Sandbox Code Playgroud)
...
androidTestCompile('org.robolectric:robolectric:2.4-SNAPSHOT') {
Run Code Online (Sandbox Code Playgroud)
我在这里提出了一个问题:https://github.com/robolectric/robolectric/issues/1332(详情请看这里).
这是我得到的错误:
java.lang.RuntimeException: Could not find any resource from reference ResName{com.fada21.android.bootstrap:style/Theme_AppCompat_Light_NoActionBar} from style StyleData{name='AppTheme', parent='Theme_AppCompat_Light_NoActionBar'} with theme null
at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getParent(ShadowAssetManager.java:456)
at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getAttrValue(ShadowAssetManager.java:394)
at org.robolectric.shadows.ShadowResources.getOverlayedThemeValue(ShadowResources.java:297)
at org.robolectric.shadows.ShadowResources.findAttributeValue(ShadowResources.java:286)
at org.robolectric.shadows.ShadowResources.attrsToTypedArray(ShadowResources.java:189)
at org.robolectric.shadows.ShadowResources.access$000(ShadowResources.java:48)
at org.robolectric.shadows.ShadowResources$ShadowTheme.obtainStyledAttributes(ShadowResources.java:494)
at org.robolectric.shadows.ShadowResources$ShadowTheme.obtainStyledAttributes(ShadowResources.java:489)
at org.robolectric.shadows.ShadowResources$ShadowTheme.obtainStyledAttributes(ShadowResources.java:484)
at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java) …Run Code Online (Sandbox Code Playgroud) 有没有人加入MergeAdapter,StickyListHeaders和ListViewAnimations安卓库?
我的需求是:
我的演员:
Cherrypick:
提到的图书馆是:
如果有可能,请给我一些希望,以及如何避免陷阱的一些有用提示.也许我应该使用其他一些库.或者我只需要自己写一下:(
==== ==== EDITED
最后,我设法建立了我希望做的事情(2014年初).它是功能可扩展和可拖动的listview和适配器库,具有漂亮的动画(还没有粘性标头).回购:
由于RecyclerView现在可用,因此无需使用过于复杂的列表视图代码.这是快速切换指南 - http://andraskindler.com/2014/11/22/migrating-to-recyclerview/.
在我们的应用程序分析中,我们注意到getIntent().getExtras()呼叫崩溃的数量有所增加。它是间歇性的,我们无法复制它。
崩溃有两种情况:
12 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Parcel.dataSize()' on a null object reference
13 at android.os.BaseBundle.<init>(BaseBundle.java:126)
14 at android.os.Bundle.<init>(Bundle.java:102)
15 at android.content.Intent.getExtras(Intent.java:5685)
Run Code Online (Sandbox Code Playgroud)
和
12 Caused by: java.lang.IllegalArgumentException
13 at android.os.Parcel.nativeAppendFrom(Native Method)
14 at android.os.Parcel.appendFrom(Parcel.java:458)
15 at android.os.BaseBundle.<init>(BaseBundle.java:126)
16 at android.os.Bundle.<init>(Bundle.java:102)
17 at android.content.Intent.getExtras(Intent.java:5685)
Run Code Online (Sandbox Code Playgroud)
检索代码基本上如下onResume() {... getIntent().getExtras() ...}。我们检查包是否不为空,但它在此之前崩溃了。
我们确实通过了自定义的可打包,但正在通过对其进行编组和解组的广泛单元测试。
这些崩溃的有趣统计数据是,它主要发生在 Android 6+ 上(记录的 72% 的会话中,95% 的崩溃发生在 Android 6+ 上)。此外,三星设备上很少发生意外崩溃(该制造商记录的 73% 的会话中只有 10% 发生崩溃)。
此崩溃对应用程序崩溃率造成约 0.15% 的影响,并且呈上升趋势(可能是因为 API23+ 上的数量或用户不断增加)。
有人遇到过类似的事情或者已经有解决方案了吗?
crash android parcelable android-intent android-6.0-marshmallow