hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

DirAdapter.java line 50 Crash #63

Open ytheekshana opened 5 years ago

ytheekshana commented 5 years ago

I have a crash on many devices. Firebase Crashlytics show this.

Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f080121 at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:237) at android.content.res.Resources.getDrawableForDensity(Resources.java:902) at android.content.res.Resources.getDrawable(Resources.java:842) at android.content.Context.getDrawable(Context.java:628) at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:454) at com.obsez.android.lib.filechooser.tool.DirAdapter.init(DirAdapter.java:50) at com.obsez.android.lib.filechooser.tool.DirAdapter.(DirAdapter.java:38) at com.obsez.android.lib.filechooser.ChooserDialog.build(ChooserDialog.java:473) at com.ytheekshana.deviceinfo.SettingsActivity$SettingsFragment.lambda$onCreatePreferences$4(SettingsActivity.java:155) at com.ytheekshana.deviceinfo.-$$Lambda$SettingsActivity$SettingsFragment$Y7f1g7hc3TMWquV4ySFCNsnDHKw.onPreferenceClick(Unknown Source:2) at androidx.preference.Preference.performClick(Preference.java:1169) at androidx.preference.Preference.performClick(Preference.java:1152) at androidx.preference.Preference$1.onClick(Preference.java:182) at android.view.View.performClick(View.java:7333) at android.view.View.performClickInternal(View.java:7299) at android.view.View.access$3200(View.java:846) at android.view.View$PerformClick.run(View.java:27774) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:6981) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

I am Building the FileChooser like this.

ChooserDialog chooseLocation; if (dark_theme_Pref.isChecked()) { chooseLocation = new ChooserDialog(getActivity(), R.style.FileChooserStyle_Dark); } else { chooseLocation = new ChooserDialog(getActivity()); } chooseLocation.withDateFormat("dd MMMM yyyy"); chooseLocation.displayPath(false); chooseLocation.enableOptions(true); chooseLocation.withResources(R.string.file_chooser_title, R.string.file_chooser_choose, R.string.cancel); chooseLocation.withFilter(true, false); chooseLocation.withStartFile(Environment.getExternalStorageDirectory().getAbsolutePath()); chooseLocation.withChosenListener((path, pathFile) -> { shareEdit.putString("extract_location", path); shareEdit.apply(); shareEdit.commit(); pref_extract_location.setSummary(path); }); chooseLocation.build(); chooseLocation.show();

Guiorgy commented 5 years ago

ResourcesNotFoundException, that's strange. Haven't been able to reproduce this either. Did cleaning, and rebuilding not help?

ytheekshana commented 5 years ago

ResourcesNotFoundException, that's strange. Haven't been able to reproduce this either. Did cleaning, and rebuilding not help?

nope

hedzr commented 5 years ago

In checking. poor network speed at these days. i can't reply to gitter but i'm here.

ytheekshana commented 5 years ago

Thanks. Here's a list of device that had this crash 1 2 3 4 5

hedzr commented 5 years ago

the first, it seems the R.drawable.ic_folder missed. ic_folder is in afc library, it should be there if the gradle import is right. could you check that and show us your import line.

let's suppose the import is wrong, it will cause resource not found exception on any devices.

ytheekshana commented 5 years ago

You mean this ?

dependencies { implementation fileTree(include: ['.jar', '.aar'], dir: 'libs') implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha5' androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0-alpha05', { exclude group: 'com.android.support', module: 'support-annotations' }) testImplementation 'junit:junit:4.13-beta-2' implementation 'com.google.firebase:firebase-crash:16.2.1' implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-messaging:17.6.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' implementation 'androidx.appcompat:appcompat:1.1.0-alpha04' implementation 'com.google.android.material:material:1.1.0-alpha05' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04' implementation 'androidx.biometric:biometric:1.0.0-alpha04' implementation 'com.android.billingclient:billing:1.2' implementation 'com.github.kizitonwose.colorpreference:core:1.1.0' implementation 'com.github.kizitonwose.colorpreference:support:1.1.0' implementation 'com.jaredrummler:android-device-names:1.1.8' implementation 'com.github.nisrulz:lantern:2.0.0' implementation 'com.ogaclejapan.smarttablayout:library:2.0.0' implementation 'com.github.lzyzsd:circleprogress:1.2.1' implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha' implementation 'com.nabinbhandari.android:permissions:3.8' implementation 'com.obsez.android.lib.filechooser:filechooser:1.1.19' implementation 'com.nex3z:toggle-button-group-x:0.1.0' }

hedzr commented 5 years ago

Yes it is. But it looks good. I just created an demo-app, it works. would you like give it a shot? afc-demo.zip

ytheekshana commented 5 years ago

Yes it is. But it looks good. I just created an demo-app, it works. would you like give it a shot? afc-demo.zip

I don't have those devices. They just poped up on Firebase crashlytics. This doesn't happen on my device.

hedzr commented 5 years ago

They dislike me. It's a bad news. I'll link to Firebase console to trace this issue. Thanks.

hedzr commented 5 years ago

image

test lab say ok with afc-demo (added crushlytics, robo test just click button to display afc dialog).

ytheekshana commented 5 years ago

@hedzr I could add you to my Firebase console so that you'll get more info about the crash. Is it ok? If yes send me your Gmail.

hedzr commented 5 years ago

hedzrz@gmail.com i'll in after two hours

ytheekshana commented 5 years ago

Added the email. You'll find the crash in the crashlytics crash list. It will be the second one. Thanks

Guiorgy commented 5 years ago

Perhaps the Proguard/R8 messes with the resources. do you by chance shrinkResources true? Edit:

Google launches Android Studio 3.4 with Android Q Beta emulator, andR8 replaces Proguard

Even though it should be R8 by default now, I did explicitly enable it (android.enableR8=true), and added it to the dependencies (classpath 'com.android.tools:r8:1.3.52'). Might be worth looking into that?

ytheekshana commented 5 years ago

Perhaps the Proguard/R8 messes with the resources. do you by chance shrinkResources true? Edit:

Google launches Android Studio 3.4 with Android Q Beta emulator, andR8 replaces Proguard

Even though it should be R8 by default now, I did explicitly enable it (android.enableR8=true), and added it to the dependencies (classpath 'com.android.tools:r8:1.3.52'). Might be worth looking into that?

By the time of the exception, shrinkResourse is false....

hedzr commented 5 years ago

@ytheekshana we released the library with standard mode, no shrinkResource, and android.enableR8 is true. You could make choice of the final strategy in your app, which will take affect to both of app and lib.

ytheekshana commented 5 years ago

image

jangrewe commented 3 years ago

I'm also getting this error, on devices with Android 6.0.1 and older: image Unfortunately there's no API 21 system image for AVD anymore, so i can't test it myself. I do have shrinkResources true, would this maybe help? https://developer.android.com/studio/build/shrink-code#keep-resources