0

My app works fine on the simulator and on my physical device when I run via Android Studio, but it immediately crashes when I use a signed APK (or install it from Play Store). I used Android Studio's Firebase Assistant to setup everything.

Here's my onCreate:

FirebaseDatabase database = FirebaseDatabase.getInstance();
        database.setPersistenceEnabled(true);
        DatabaseReference myRef = database.getReference();

        final Activity context = this;
        // Read from the database
        myRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {

                GenericTypeIndicator<List<University>> genericTypeIndicator = new GenericTypeIndicator<List<University>>() {};
                colleges = dataSnapshot.getValue(genericTypeIndicator);

                List<String> names = new ArrayList<String>();

                for (University college : colleges){
                    names.add(college.name);
                }

                if (colleges.size() > 0) {
                    CustomList customList = new CustomList(context, colleges, names);
                    listView.setAdapter(customList);
                    setListeners();
                }

            }

            @Override
            public void onCancelled(DatabaseError error) {
                // Failed to read value
                Log.w(TAG, "Failed to read value.", error.toException());
            }
        });
AL.
  • 36,815
  • 10
  • 142
  • 281
Mochi
  • 47
  • 1
  • 8
  • What is exception that you are getting? You could share stacktrace. – Jakub Szczygieł Jun 06 '17 at 19:57
  • @JakubSzczygieł com.google.firebase.database.DatabaseException – Mochi Jun 06 '17 at 20:30
  • Mohammed, yes but stack trace would be useful. – Jakub Szczygieł Jun 06 '17 at 21:00
  • If Proguard is set to obfuscate your files, (`minifyEnabled=true`), this may be the problem. If so, see [this](https://stackoverflow.com/questions/6533676/proguard-and-gson-on-android-classcastexception?rq=1). It's a different exception but it may help. – Gary99 Jun 06 '17 at 21:01
  • @JakubSzczygieł unfortunately, I couldn't get any more information because it doesn't crash when running via Android Studio. I got this from Google Play Console. – Mochi Jun 06 '17 at 21:42
  • Ok, so what was the message associated with this DatabaseException if any? – Jakub Szczygieł Jun 06 '17 at 21:47
  • @Gary99 I have `minifyEnabled = false`, and setting it to false results in `Execution failed for task: app:tranformClassesAndResourcesWithProguardForRelease.` – Mochi Jun 06 '17 at 21:49
  • 1
    @JakubSzczygieł I could get this report from my users: `at com.google.firebase.database.DataSnapshot.getValue(Unknown Source:0) at com.geekMohammad.itotal.MainActivity$1.onDataChange(MainActivity.java:72)` ~ It crashes at onDataChange – Mochi Jun 06 '17 at 22:11
  • You can upload your proguard mapping to Google play console to get the full stacktrace – OneCricketeer Jun 07 '17 at 03:04
  • Well unless you upload proguard mapping to play console as @cricket_007 mentioned, you can use fabric.io or other crash tool that will gather more information about crashes (and again with mapping) will allow you to figure out what is wrong. – Jakub Szczygieł Jun 07 '17 at 20:52

0 Answers0