【问题标题】:Not able to generate signed APK?无法生成签名的 APK?
【发布时间】:2020-06-29 19:34:01
【问题描述】:

我正在尝试生成签名的 APK。但由于生成时的 lint 错误而无法生成它。我检查了我的 lint 报告,它在我的 XML 文件中显示错误。

“NotSibling”类型问题的解释: 给定 ConstraintLayout 或 RelativeLayout 中的布局约束应该 引用同一相对布局中的其他视图(但不引用自身!)

1 个错误,0 个警告

FAILURE:构建失败并出现异常。

  • 出了什么问题:任务 ':app:lintVitalRelease' 执行失败。

    Lint 在组装发布目标时发现致命错误。 要继续,请修复 lint 确定的问题,或按如下方式修改构建脚本: ... android { lintOptions { checkReleaseBuilds 错误 // 或者,如果您愿意,您可以继续检查发布版本中的错误, // 但即使发现错误也要继续构建: abortOnError 错误

这是我的 XML:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:background="@color/background">

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/all_featured_deals_divider"
        android:orientation="vertical"
        android:overScrollMode="never">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="3dp"
        android:paddingRight="6dp"
        android:paddingLeft="6dp"
        android:paddingBottom="3dp">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/notificationsRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:nestedScrollingEnabled="false"/>

    </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</RelativeLayout>

在这一行出现错误:

    android:layout_below="@+id/all_featured_deals_divider"

../../src/main/res/layout/notification_view.xml:48: @+id/all_featured_deals_divider 不是同级的兄弟 相对布局

错误是:给定 ConstraintLayout 或 RelativeLayout 中的布局约束应该引用同一相对布局中的其他视图(但不是自身!)

【问题讨论】:

  • 去掉那一行 android:layout_below

标签: java android xml android-layout


【解决方案1】:

删除android:layout_below="@+id/all_featured_deals_divider"

如果您正在重用 xml,例如使用包含,在那里做约束。

【讨论】:

    【解决方案2】:

    您的@+id/all_featured_deals_divider 不引用当前 xml 文件中的任何元素。

    您可能从其他一些 XML 文件中复制了布局,其中存在同名元素但未包含在此处。您可以删除这一行,因为它没有用,并且您的代码应该不会显示任何错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      相关资源
      最近更新 更多