【发布时间】:2019-12-08 12:50:21
【问题描述】:
我在我的应用程序中使用databinding,它运行良好。但是当我启用minifyEnabled true 和shrinkResources true 时,它会显示一些错误。
Execution failed for task':app:transformClassesAndResourcesWithR8ForDebug'.
Caused by: com.android.tools.r8.utils.AbortException: Error: D:\TUK_Sep_Conclave\TUK_Septmber\app\build\intermediates\proguard-rules\debug\aapt_rules.txt, offset: 48276, line: 457, column: 33, Expected field or method name at D:\TUK_Sep_Conclave\TUK_Septmber\app\build\intermediates\proguard-rules\debug\aapt_rules.txt:457:33
-keepclassmembers class * { *** @{(view)->listener.onClick(view)}(android.view.View); }
^
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:101)
Suppressed: com.android.tools.r8.shaking.ProguardRuleParserException: Expected field or method name at D:\TUK_Sep_Conclave\TUK_Septmber\app\build\intermediates\proguard-rules\debug\aapt_rules.txt:457:33
-keepclassmembers class * { *** @{(view)->listener.onClick(view)}(android.view.View); }
而我的layout.xml 是
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.ui.user.activity.ContactUsActivity"
tools:ignore="HardcodedText">
<data>
<variable
name="listener"
type="com.example.ui.user.activity.ContactUsActivity" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/action_call_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:onClick="@{(view)->listener.onClick(view)}"
android:padding="3dip"
android:text="+91-1234567890"
android:textColor="@android:color/white"
android:textSize="12sp" />
</LinearLayout>
</layout>
现在我的问题是如何为 android 数据绑定和点击监听器编写 progaurd 规则。任何帮助将不胜感激,谢谢。
【问题讨论】:
-
@SumitShukla 我试过这个,但没有帮助。
-
你确定是这个错误吗?
-
@coroutineDispatcher 在我尝试构建项目时发生。
-
就我而言,我有一个带有 android:onClick="@{(view)->listener.onClick(view)}" 的文件,但布局没有数据绑定(我没有注入监听器,并且布局没有
标签)。我是通过复制粘贴得到的????
标签: android proguard android-databinding android-r8