Android-FilePicker
Android-FilePicker copied to clipboard
App crash when try to Pick a File when I am using 28.0.0 (compileSdkversion & targetSdkVersion)
Its version do the application crash -> compileSdkVersion 28 buildToolsVersion '28.0.3' targetSdkVersion 28
-> If I downgrade it to 27
compileSdkVersion 27 buildToolsVersion '27.0.3' targetSdkVersion 27
It works perfectly
Same error with me. I rolled back to 27.1.1 to make it work. Hope he fixes this ASAP.
Only file picker crashes. Photo picker works fine for me.
I have the same issue.
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) {
HashMap<FileType, List<Document>> documentMap = new HashMap<>();
for (final FileType fileType : fileTypes) {
ArrayList<Document> documentListFilteredByType = new ArrayList<>();
for (Document doc: documents) {
if (doc.isThisType(fileType.extensions)) {
documentListFilteredByType.add(doc);
}
}
if (comparator != null) Collections.sort(documentListFilteredByType, comparator);
documentMap.put(fileType, documentListFilteredByType);
}
return documentMap;
}
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }
Sorry man! I was a little bit busy! I could not reply beofre. I will try it! So, Should I do a Fork?
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }Sorry man! I was a little bit busy! I could not reply beofre. I will try it! So, Should I do a Fork?
Yes, need to make fork. Also, you should use support library version 28.0.0
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }
Did you add something else? I put your code it is ok! But I having issues with Predicate<T> I already imported it but it doesn know .apply function inside of FilePickerUtils
`public static <T> Collection<T> filter(Collection<T> target, Predicate<T> predicate) {
Collection<T> result = new ArrayList<T>();
for (T element : target) {
if (predicate**.apply**(element)) {
result.add(element);
}
}
return result;
}`
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }Did you add something else? I put your code it is ok! But I having issues with Predicate I already imported it but it doesn know .apply function inside of FilePickerUtils
`public static <T> Collection<T> filter(Collection<T> target, Predicate<T> predicate) { Collection<T> result = new ArrayList<T>(); for (T element : target) { if (predicate**.apply**(element)) { result.add(element); } } return result; }`
You can delete method 'filter'. It is doesn't need after changes in DocScannerTask class.
try out new version 2.2.0 with androidx
I've updated the library to 2.2.0 and my project to androidx as well but i was still getting a crash when i use the pickFile option. I've resolved the issue by adding .sortDocumentsBy(SortingTypes.name) to the builder method though. Using .sortDocumentsBy(SortingTypes.none) also caused a crash.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.world.lynkedworld/droidninja.filepicker.FilePickerActivity}: java.lang.IllegalStateException: PickerManager.sortingType.comparator must not be null at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalStateException: PickerManager.sortingType.comparator must not be null at droidninja.filepicker.fragments.DocPickerFragment.setData(DocPickerFragment.kt:82) at droidninja.filepicker.fragments.DocPickerFragment.initView(DocPickerFragment.kt:66) at droidninja.filepicker.fragments.DocPickerFragment.onViewCreated(DocPickerFragment.kt:61) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1471) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273) at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620) at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237) at android.app.Activity.performStart(Activity.java:6253) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@DroidNinja I have migrated my project to androidx and updated dependency to 2.2.0
I had to change my code of file picker from:
FilePickerBuilder.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);
to:
FilePickerBuilder.Companion.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);
Now when i tested the app after setting max compileSdkVersion to 28 i get this error: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; at droidninja.filepicker.FilePickerBuilder.setSelectedFiles(Unknown Source:2)
@DroidNinja I have migrated my project to androidx and updated dependency to 2.2.0
I had to change my code of file picker from:
FilePickerBuilder.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);to:
FilePickerBuilder.Companion.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);Now when i tested the app after setting max compileSdkVersion to 28 i get this error: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; at droidninja.filepicker.FilePickerBuilder.setSelectedFiles(Unknown Source:2)
Add this to your app level build.gradle
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41'
@DroidNinja I have migrated my project to androidx and updated dependency to 2.2.0 I had to change my code of file picker from:
FilePickerBuilder.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);to:FilePickerBuilder.Companion.getInstance().setMaxCount(1) .setSelectedFiles(filePaths) .setActivityTheme(R.style.LibAppTheme) .pickPhoto(this);Now when i tested the app after setting max compileSdkVersion to 28 i get this error: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; at droidninja.filepicker.FilePickerBuilder.setSelectedFiles(Unknown Source:2)Add this to your app level build.gradle
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41'
Thanks, that error is gone. But here is the new error I'm getting while picking file:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.scoratech.scoraxchange.devbuild/droidninja.filepicker.FilePickerActivity}: java.lang.IllegalStateException: PickerManager.sortingType.comparator must not be null at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2779) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
But here is the new error I'm getting while picking file:
I also have this error
But here is the new error I'm getting while picking file:
I also have this error
check my previous replies.
Here is the solution I've resolved the issue by adding .sortDocumentsBy(SortingTypes.name) to the builder method.
I solved this by :- (1.) Adding following to App Level build.gradle ->
dependency{
...
implementation 'com.droidninja:filepicker:2.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71"
...
}
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains' , module:'annotations'
}
(2) Changing ->
FilePickerBuilder.getInstance().setMaxCount(1)
.setSelectedFiles(file_paths)
.setActivityTheme(R.style.FilePickerTheme)
.pickPhoto(this);
--- TO ---
FilePickerBuilder.Companion.getInstance().setMaxCount(1)
.setSelectedFiles(file_paths)
.setActivityTheme(R.style.FilePickerTheme)
.sortDocumentsBy(SortingTypes.name)
.pickPhoto(this);
I solved this by :- (1.) Adding following to App Level build.gradle ->
dependency{ ... implementation 'com.droidninja:filepicker:2.2.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71" ... } configurations { cleanedAnnotations compile.exclude group: 'org.jetbrains' , module:'annotations' }(2) Changing ->
FilePickerBuilder.getInstance().setMaxCount(1) .setSelectedFiles(file_paths) .setActivityTheme(R.style.FilePickerTheme) .pickPhoto(this);--- TO ---FilePickerBuilder.Companion.getInstance().setMaxCount(1) .setSelectedFiles(file_paths) .setActivityTheme(R.style.FilePickerTheme) .sortDocumentsBy(SortingTypes.name) .pickPhoto(this);
You moved your project your AndroidX?and tested both file and photo picker?
I tried @dishantghai changes.
Getting this error:
error: cannot access Fragment class file for androidx.fragment.app.Fragment not found
I tried @dishantghai changes.
Getting this error:
error: cannot access Fragment class file for androidx.fragment.app.Fragment not found
i have same error
download last comment before converted to kotlin from this link : https://github.com/DroidNinja/Android-FilePicker/tree/95216ceeeac3ea95939f6fcf0d1d18ea320d4829 then you can update the compileSdkVersion 28 targetSdkVersion 26
then add implementation project(path: ':filepicker', configuration: 'default')
then go to DocScannerTask replace
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { Predicate<Document> docContainsTypeExtension = new Predicate<Document>() { public boolean apply(Document document) { return document.isThisType(fileType.extensions); } }; ArrayList<Document> documentListFilteredByType = (ArrayList<Document>) FilePickerUtils.filter(documents, docContainsTypeExtension); if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }
To
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) {HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }
then Go to FilePickerUtils And remove
public static <T> Collection<T> filter(Collection<T> target, Predicate<T> predicate) { Collection<T> result = new ArrayList<T>(); for (T element : target) { if (predicate**.apply**(element)) { result.add(element); } } return result; }
@KhanStan99
tried @dishantghai changes.
Getting this error:
error: cannot access Fragment class file for androidx.fragment.app.Fragment not found
Any solution to this issue yet..?
@DroidNinja Please help us out. Can we use your library on latest SDK without migrating to androidx ?
I have the same issue.
I tried @dishantghai changes.
Getting this error:
error: cannot access Fragment class file for androidx.fragment.app.Fragment not found
Is anyone find solution for this issue?
I can't find hope to fix the bug as soon as possible
have this issue too
Please help to fix this issues. :(
I solved this by :- (1.) Adding following to App Level build.gradle ->
dependency{ ... implementation 'com.droidninja:filepicker:2.2.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71" ... } configurations { cleanedAnnotations compile.exclude group: 'org.jetbrains' , module:'annotations' }(2) Changing ->
FilePickerBuilder.getInstance().setMaxCount(1) .setSelectedFiles(file_paths) .setActivityTheme(R.style.FilePickerTheme) .pickPhoto(this);--- TO ---FilePickerBuilder.Companion.getInstance().setMaxCount(1) .setSelectedFiles(file_paths) .setActivityTheme(R.style.FilePickerTheme) .sortDocumentsBy(SortingTypes.name) .pickPhoto(this);You moved your project your AndroidX?and tested both file and photo picker?
Awesome. The .sortDocumentsBy(SortingTypes.name) works with androidX both file and photo picker
Change compileSdkVersion to version 28 and then override method createDocumentType of DocScannerTask.java like this
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }
How to do that with the gradle dependancy 2.2.0?
download last comment before converted to kotlin from this link : https://github.com/DroidNinja/Android-FilePicker/tree/95216ceeeac3ea95939f6fcf0d1d18ea320d4829 then you can update the compileSdkVersion 28 targetSdkVersion 26
then add implementation project(path: ':filepicker', configuration: 'default')
then go to DocScannerTask replace
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) { HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { Predicate<Document> docContainsTypeExtension = new Predicate<Document>() { public boolean apply(Document document) { return document.isThisType(fileType.extensions); } }; ArrayList<Document> documentListFilteredByType = (ArrayList<Document>) FilePickerUtils.filter(documents, docContainsTypeExtension); if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }To
private HashMap<FileType, List<Document>> createDocumentType(ArrayList<Document> documents) {HashMap<FileType, List<Document>> documentMap = new HashMap<>(); for (final FileType fileType : fileTypes) { ArrayList<Document> documentListFilteredByType = new ArrayList<>(); for (Document doc: documents) { if (doc.isThisType(fileType.extensions)) { documentListFilteredByType.add(doc); } } if (comparator != null) Collections.sort(documentListFilteredByType, comparator); documentMap.put(fileType, documentListFilteredByType); } return documentMap; }then Go to FilePickerUtils And remove
public static <T> Collection<T> filter(Collection<T> target, Predicate<T> predicate) { Collection<T> result = new ArrayList<T>(); for (T element : target) { if (predicate**.apply**(element)) { result.add(element); } } return result; }@KhanStan99
fix this isuue
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName version
}
implementation 'com.github.bumptech.glide:glide:4.8.0'