小编chd*_*yra的帖子

将Google Play服务从8.4.0更新为9.2.1会导致Gradle同步错误

当我将Gradle文件中的Google Play依赖项从版本8.4.0更新到9.2.1时,出现以下错误:

错误:无法解决:com.google.android.gms:play-services-measurement:9.2.1

使用版本8.4.0时,这不是问题.我试图将它作为一个明确的依赖包括在内但没有任何区别.我正在使用的具体依赖项是:

compile 'com.google.android.gms:play-services-maps:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.android.gms:play-services-plus:9.2.1'
Run Code Online (Sandbox Code Playgroud)

对于为什么会发生这种情况有任何指示,我将不胜感激.

android gradle google-play-services android-studio

12
推荐指数
1
解决办法
5876
查看次数

使用播放服务12.0.0时自动添加权限READ_PHONE_STATE

我更改了我的gradle构建文件以使用最新的Google Play服务版本(11.8.0 - > 12.0.0)并将APK上传到Google Play控制台.当我试图发布时,我收到一条警告,即已添加READ_PHONE_STATE权限.如果我回滚到11.8.0,则此警告消失.

我使用以下服务:

implementation 'com.google.android.gms:play-services-auth:12.0.0'
implementation 'com.google.android.gms:play-services-plus:12.0.0'
api 'com.google.android.gms:play-services-maps:12.0.0'
api 'com.google.android.gms:play-services-location:12.0.0'
api 'com.google.android.gms:play-services-places:12.0.0'
Run Code Online (Sandbox Code Playgroud)

它似乎被自动添加到生成的manifest.xml中,即使我不需要此权限(至少我没有为播放服务11.8.0).环顾四周,似乎在未在包含的库中声明minSdk/targetSdk时出现问题.

有谁知道发生了什么,我怎么能摆脱这个许可?

谢谢,Riz

编辑:这是由主持人标记为完全重复的为什么添加了READ_PHONE_STATE权限?.不幸的是,该问题的解决方案是Play服务在10.0.1中更新以解决此问题.似乎版本12.0.0重新引入了这个问题,所以我正在寻找解决方案.

android google-play android-permissions google-play-services google-play-console

9
推荐指数
0
解决办法
583
查看次数

恢复活动时,Scrollview会变黑

当我使用ScrollView离开活动然后返回它时,ScrollView变黑.在发布时,颜色是正确的.只是当我离开并返回时它变黑了.我已经尝试设置ScrollView和内部LinearLayouts的背景,但它没有任何区别.ScrollView会被ViewPager中的片段夸大,以防万一.

任何想法为什么会出现这种情况?

这是XML

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll_formatted"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false">

    <LinearLayout style="@style/LinearLayoutVertical">

        <ImageView
            android:id="@+id/image_formatted"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:contentDescription="@string/image_review_cd"
            android:scaleType="centerCrop"/>

        <LinearLayout
            style="@style/LinearLayoutVertical.WrappedVertical"
            android:id="@+id/subject_rating_formatted">

            <TextView
            android:id="@+id/subject_formatted"
            style="@style/TextView.Subject.Bold"
            android:background="?darkBackground"/>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="?darkBackground">

            <RatingBar
                android:id="@+id/rating_formatted"
                style="@style/RatingBarFiveStar.Indicator.PointOneStep"
                android:background="?darkBackground"/>
            </FrameLayout>

            <TextView
                android:id="@+id/stamp_formatted"
                style="@style/FormattedText.Stamp"
                android:background="?darkBackground"/>
        </LinearLayout>

        <TextView
            android:id="@+id/headline_formatted"
            style="@style/TextView.Headline"/>

        <TextView
            android:id="@+id/tags_formatted"
            style="@style/FormattedTitleValue"/>

        <include
            android:id="@+id/comment_formatted"
            layout="@layout/formatted_title_value"/>

        <include
            android:id="@+id/locations_formatted"
            layout="@layout/formatted_title_value"/>

        <include
            android:id="@+id/criteria_formatted"
            layout="@layout/formatted_title_value"/>

        <include
            android:id="@+id/facts_formatted"
            layout="@layout/formatted_title_value"/>

        <include
            android:id="@+id/images_formatted"
            layout="@layout/formatted_title_data"/>

    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

编辑:这是活动和片段:

活动

public class ActivityFormatReview extends FragmentActivity implements LaunchableUi,
        OptionSelectListener, FormattedPagerAdapter.FragmentsObserver {
    private static final String TAG …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview

5
推荐指数
1
解决办法
314
查看次数

使用 Android SDK 使用对象而不是 JSON 原语的 Firebase updateChildren()

我可以updateChildren()像使用任意(Firebase 友好)对象的地图一样使用吗setValue()?以下工作正常:

public void addReview(FbReview review, AddCallback callback) {
    Firebase root = mDataRoot.child(REVIEWS_ROOT).child(review.getReviewId());
    root.setValue(review, newAddListener(review, callback));
}
Run Code Online (Sandbox Code Playgroud)

其中 FbReview 是一个简单的数据持有者类,具有空构造函数和用于自动数据结构的 getter(setValue()在 Firebase 文档中显示setValue()中使用对象)

但是,如果我尝试updateChildren()网页中的等效后续示例:

@Override
public void addReview(FbReview review, AddCallback callback) {
    Map<String, Object> updates = new HashMap<>();
    updates.put(REVIEWS_ROOT + "/" + review.getReviewId(), review);
    mDataRoot.updateChildren(updates, newAddListener(review, callback));
}
Run Code Online (Sandbox Code Playgroud)

我收到一条错误,表明无法解析我定义的 FbReview 对象:

FirebaseException:无法解析具有类的节点... FbReview

如果我尝试上面的updateChildren()代码,但传递一个字符串(review.getSubject()比如说)而不是一个对象,它工作得很好,表明对象解析不适用于updateChildren().

它是否正确?

android firebase firebase-realtime-database

3
推荐指数
1
解决办法
3117
查看次数