I got this error while trying to generate the signed APK. The thing is, my app is able to run and debug normally on my device. I don\'t know why when I try to generate APK, this
It is in the Fragment's contract: "Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle) and later retrieved by the Fragment with getArguments()."
For me only worked the combination of the two previous answers:
android {
lintOptions {
disable 'ValidFragment'
checkReleaseBuilds false
}
}
But remember, these a bad patch to avoid lint warnings/errors, the solution is to adapt the Fragment constructor to a public static Fragment newInstance(params) Fragment constructor.
turning off lint
completely is not a decent solution if you still want to use the advantages of it. If anyone comes across this, I find turning off the specific error only a more elegant solution:
android {
lintOptions {
disable 'ValidFragment'
}
}
Found the solution. The easier way is to add these to the gradle:
android {
lintOptions {
checkReleaseBuilds false
}
}
Or another way is to add @SuppressLint("ValidFragment")