Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore the "avoid non-default constructors in fragments" error?

Tags:

android

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 error came out. How to ignore this error and generate the signed APK? I am using Android Studio 1.2.1.1 for Mac.

like image 925
user2872856 Avatar asked Jun 03 '15 13:06

user2872856


People also ask

Why is it recommended to use only the default constructor to create a fragment?

Traditionally, a Fragment instance could only be instantiated using its default empty constructor. This is because the system would need to reinitialize it under certain circumstances like configuration changes and the app's process recreation.

How do I use fragment Newinstance?

The correct way to instantiate a new fragment and passing values to it, is by creating a bundle, setting arguments on this bundle and then passing it to our fragment. Inside the fragment we then retrieve this bundle and get the values out of it. A clean way to do this is by creating a so called “factory method”.


1 Answers

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")

like image 153
user2872856 Avatar answered Oct 04 '22 16:10

user2872856