小编Cha*_*ere的帖子

Google Play服务库更新和缺少符号@ integer/google_play_services_version

将我的项目升级到最新版本的Google Play服务(v4.0,在2013年万圣节发布)时,您现在应该在AndroidManifest.xml文件中添加新标记.

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
Run Code Online (Sandbox Code Playgroud)

不幸的是,当我尝试这样做时,我得到了这个编译错误:

android-apt-compiler: /blahblah/AndroidManifest.xml:409: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
Run Code Online (Sandbox Code Playgroud)

然后我可以导航到该文件google-play-services_lib/res/values/version.xml并查看该符号的原始整数:

<integer name="google_play_services_version">4030500</integer>
Run Code Online (Sandbox Code Playgroud)

然后将其插回我的AndroidManifest.xml:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="4030500" />
Run Code Online (Sandbox Code Playgroud)

这样做非常好,我可以编译并运行项目和应用程序就好了.但它绝对是一个不可取的解决方案,具有明显的可升级性问题.

有任何想法吗?

android google-play-services

186
推荐指数
11
解决办法
21万
查看次数

不推荐使用Robolectric RuntimeEnvironment.application,其中是ApplicationProvider.getApplicationContext()?

我从3.8切换到Robolectric 4.0 Beta 1,因为我需要兼容Android 9(API 28).

通过此更改,RuntimeEnvironment.application现已弃用.

替换显然是使用:

androidx.test.core.app.ApplicationProvider.getApplicationContext()

我不知道这段代码究竟在哪里.它必须完全在一个单独的依赖项中.它在哪里?如何将其添加到我的项目中?

谢谢!

android robolectric android-9.0-pie

24
推荐指数
1
解决办法
6112
查看次数

Moshi 1.9.x 无法序列化 Kotlin 类型

升级到Moshi 1.9.1(从1.8.0 开始)后,我遇到了以下崩溃和堆栈跟踪:

java.lang.IllegalArgumentException: Cannot serialize Kotlin type com.garpr.android.data.models.RankedPlayer. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapter from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
for class com.garpr.android.data.models.RankedPlayer
for class com.garpr.android.data.models.AbsPlayer

    at com.squareup.moshi.Moshi$LookupChain.exceptionWithLookupStack(Moshi.java:349)
    at com.squareup.moshi.Moshi.adapter(Moshi.java:150)
    at com.squareup.moshi.Moshi.adapter(Moshi.java:98)
    at com.squareup.moshi.AdapterMethodsFactory$AdapterMethod.bind(AdapterMethodsFactory.java:313)
    at com.squareup.moshi.AdapterMethodsFactory.create(AdapterMethodsFactory.java:62)
    at com.squareup.moshi.Moshi.adapter(Moshi.java:138)
    at com.squareup.moshi.Moshi.adapter(Moshi.java:98)
    at com.squareup.moshi.Moshi.adapter(Moshi.java:72)
    at com.garpr.android.data.converters.AbsPlayerConverterTest.setUp(AbsPlayerConverterTest.kt:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) …
Run Code Online (Sandbox Code Playgroud)

android json robolectric moshi

17
推荐指数
3
解决办法
7410
查看次数

android.os.BadParcelableException:解组时的ClassNotFoundException:com.facebook.flatbuffers.helpers.FlatBufferModelHelper $ LazyHolder

我在Crashlytics看到了这个目前正在制作的应用程序的崩溃:

Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.facebook.flatbuffers.helpers.FlatBufferModelHelper$LazyHolder
   at android.os.Parcel.readParcelableCreator(Parcel.java:2295)
   at android.os.Parcel.readParcelable(Parcel.java:2245)
   at android.os.Parcel.readValue(Parcel.java:2152)
   at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
   at android.os.BaseBundle.unparcel(BaseBundle.java:221)
   at android.os.BaseBundle.containsKey(BaseBundle.java:269)
   at android.content.Intent.hasExtra(Intent.java:5632)
   ...
Run Code Online (Sandbox Code Playgroud)

我真的不确定导致这个问题的原因.我甚至找不到facebook-android-sdk中FlatBufferModelHelper课程.

不幸的是,我真的没有比这更多的信息了.此崩溃似乎会影响所有API级别的所有设备.

感谢您的任何信息!

android parcel badparcelableexception android-facebook

11
推荐指数
0
解决办法
440
查看次数

Android 5.0(Lollipop)CheckedTextView按突出显示问题

在Android 5.0 Lollipop上运行时,我对使用CheckedTextViewsRecyclerView感到沮丧.棒棒糖之前的所有版本都很好,并没有出现这个问题.请查看下面的图片以便更好地理解:

预棒棒糖

前棒棒糖截图

棒糖

棒棒糖截图

了解Lollipop如何仅在CheckedTextView的复选框部分上绘制选择突出显示?Pre-Lollipop没有此问题/ bug,并在视图的整个宽度上绘制选择突出显示(这是我想要的行为).

这是我正在绘制到列表中的CheckedTextView:

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="?attr/selectableItemBackground"
    android:checkMark="@drawable/checkbox"
    android:id="@+id/model_checkable_name"
    android:layout_height="48dp"
    android:layout_width="match_parent" />
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我已经尝试了各种不同的解决方案,如极少数android:focusable="false",android:duplicateParentState="true",android:duplicateParentState="false"...

多谢你们!

android checkedtextview android-5.0-lollipop android-recyclerview

7
推荐指数
1
解决办法
692
查看次数

如何构建包含具有不同compileSdkVersion,targetSdkVersion和minSdkVersion的模块的Android gradle项目?

我的Android库项目由四个模块组成:

  • 项目
    • 基础
    • V14
    • V18

以下是IntelliJ的此设置的屏幕截图:

模块

我的模块使用非常特定的Android SDK级别设置:

  • 基础
    • compileSdkVersion 19
    • minSdkVersion 14
    • targetSdkVersion 19
    • compileSdkVersion 19
    • minSdkVersion 14
    • targetSdkVersion 19
  • V14
    • compileSdkVersion 17
    • minSdkVersion 14
    • targetSdkVersion 17
  • V18
    • compileSdkVersion 18
    • minSdkVersion 18
    • targetSdkVersion 18

随着Android的更新版本的发布,基础和工厂模块可以跟随它们compileSdkVersiontargetSdkVersion级别.但是,v14和v18都绝对不能效仿.

我的模块以非常具体的方式相互依赖:

  • 基础
    • 不依赖于任何其他模块
    • 取决于base,v14和v18
  • V14
    • 取决于基数
  • V18
    • 取决于基数

所以当我去构建我的项目时,我收到了这个错误:

Error:Gradle: Execution failed for task ':v14:processReleaseManifest'.
> Manifest merging failed. See console for more info.
Run Code Online (Sandbox Code Playgroud)

在使用终端进行构建时./gradlew build --stacktrace,我会获得更多信息:

:v14:processReleaseManifest
[/blahblah/project/v14/build/exploded-aar/blahblah/base/unspecified/AndroidManifest.xml:2] Main manifest has <uses-sdk android:targetSdkVersion='17'> but …
Run Code Online (Sandbox Code Playgroud)

android gradle android-gradle-plugin

6
推荐指数
1
解决办法
2822
查看次数