0

I'm using Google Play Console to test my app before releasing it to the public and I'm getting a consistent crash on startup only on Google Pixel devices running on Android Nougat(7.1). Every other device runs the app without problems, including the same Google Pixel running on Android Oreo(8.0).

The log shows the following info:

D/AndroidRuntime(8360): Shutting down VM 11-15 13:14:46.176: 
D/AndroidRuntime(8360): --------- beginning of crash 
11-15 13:14:46.176: E/AndroidRuntime(8360): FATAL EXCEPTION: main
11-15 13:14:46.176: E/AndroidRuntime(8360): Process: com.systemallica.gallery, PID: 8360
11-15 13:14:46.176: E/AndroidRuntime(8360): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.systemallica.gallery/com.systemallica.gallery.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread.-wrap12(ActivityThread.java)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.os.Handler.dispatchMessage(Handler.java:102)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.os.Looper.loop(Looper.java:154)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread.main(ActivityThread.java:6119)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at java.lang.reflect.Method.invoke(Native Method)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
11-15 13:14:46.176: E/AndroidRuntime(8360): Caused by: java.lang.NullPointerException: Attempt to get length of null array
11-15 13:14:46.176: E/AndroidRuntime(8360):     at com.systemallica.gallery.MainActivity.b(Unknown Source)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at com.systemallica.gallery.MainActivity.onCreate(Unknown Source)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.Activity.performCreate(Activity.java:6679)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
11-15 13:14:46.176: E/AndroidRuntime(8360):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
11-15 13:14:46.176: E/AndroidRuntime(8360):     ... 9 more
11-15 13:14:46.181: W/ActivityManager(1002):   Force finishing activity com.systemallica.gallery/.MainActivity
11-15 13:14:46.186: W/ActivityManager(1002):   Force finishing activity com.systemallica.gallery/.MainActivity

Full MainActivity source: https://pastebin.com/Ar5j2fEh

The MainActivity onCreate:

public class MainActivity extends AppCompatActivity {

final int MY_PERMISSIONS_REQUEST_BOTH= 114;

@BindView(R.id.swipelayout) SwipeRefreshLayout swipeLayout;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Check for sdk >= 23
    if (Build.VERSION.SDK_INT >= 23) {
        // Check CAMERA and MEDIA permission
        if (checkSelfPermission(Manifest.permission.CAMERA)!= PERMISSION_GRANTED ||
                checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)!= PERMISSION_GRANTED ||
                checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PERMISSION_GRANTED ){
            requestPermissions(new String[]{
                            Manifest.permission.CAMERA,
                            Manifest.permission.READ_EXTERNAL_STORAGE,
                            Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    MY_PERMISSIONS_REQUEST_BOTH);
            // When permissions are granted
        }else{
            setFABListener();
            loadFolders(columns);
        }
    }

    // Set on swipe refresh listener
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            startRefresh();
        }
    });

    // Change navBar colour
    if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        int app_primary = ContextCompat.getColor(this, R.color.app_primary);
        getWindow().setNavigationBarColor(app_primary);
    }
}
}

I don't even know where to start debugging. Any idea of what the problem could be?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Systemallica
  • 106
  • 1
  • 10
  • You haven't included any of the code for the methods in your `MainActivity` which are likely causing the issue. That log says the problem is the method `MainActivity.b()`, which looks like it is being obfuscated. You either need to de-obfuscate your logs, or run the app without obfuscation to see which method it is. – Bryan Herbst Nov 21 '17 at 15:34
  • Please share full source code of MainActivity.Not enough information to figure out issue. – Pankaj Kant Patel Nov 21 '17 at 15:37
  • @Tanis.7x Okay I'll try to de-obfuscate the logs. – Systemallica Nov 21 '17 at 15:41
  • @PankajKantPatel Here you go: https://pastebin.com/Ar5j2fEh (sorry, it's a big activity) – Systemallica Nov 21 '17 at 15:42
  • What you really should do is deobfuscate the stack trace. That would point at the line where the issue is. The only thing I can see now that it's in a method called from onCreate. – jbarat Nov 21 '17 at 16:33

0 Answers0