today when I want to get a release from my project , android studio show this errorr:
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
So I open report folder of lint and see this error:
<issue
id="ResAuto"
severity="Fatal"
message="In Gradle projects, always use `http://schemas.android.com/apk/res-auto` for custom attributes"
category="Correctness"
priority="9"
summary="Hardcoded Package in Namespace"
explanation="In Gradle projects, the actual package used in the final APK can vary; for example,you can add a `.debug` package suffix in one version and not the other. Therefore, you should **not** hardcode the application package in the resource; instead, use the special namespace `http://schemas.android.com/apk/res-auto` which will cause the tools to figure out the right namespace for the resource regardless of the actual package used during the build."
errorLine1=" xmlns:app="http://schemas.android.com/apk/res/ir.app.appname">">"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
quickfix="studio">
<location
file="C:\...\app\src\main\res\color\mybutton_backgroundcolor.xml"
line="3"
column="16"/>
</issue>
mybutton_backgroundcolor.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/ir.app.appname">
<item android:state_enabled="true" app:state_read ="false" android:color="@color/backgrpund_button_success"/>
<item android:state_enabled="false" app:state_read ="false" android:color="@color/gray_4"/>
<item app:state_read ="true" android:color="@color/gray_4"/>
</selector>
the error is in this xmlns:app="http://schemas.android.com/apk/res/ir.app.appname"> line.
Can some one help me to solve this problem?!
Update:
this error occur after I update com.android.support
library to version 28
The app
namespace should be declared as xmlns:app="http://schemas.android.com/apk/res-auto"
:
As the Lint says:
In Gradle projects, the actual package used in the final APK can vary; for you can add a
.debug
package suffix in one version and not the other. Therefore, you should not hardcode the application package in the resource; instead, use the special namespacehttp://schemas.android.com/apk/res-auto
which will cause the tools to figure out the right namespace for the resource regardless of the actual package used during the build.