java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" error in Adone AIR native extension
Asked Answered
W

2

6

maybe my question sounds like asked 100 times before, but believe me I have read every answer for those 100 similar questions and non of them solved my problem. So purpose of my native extension is to share documents in my app cache folder (doc, pdf, etc.) with third party apps (Quick Office, Adobe Reader etc). I found that FileProvider and Intents should solve my problem.

My app description file contains:

<application android:enabled="true"
                android:launchMode="singleInstance">
                <provider
                    android:name="android.support.v4.content.FileProvider"
                    android:authorities="com.test.fileprovider"
                    android:exported="false"
                    android:grantUriPermissions="true">
                    <meta-data
                        android:name="android.support.FILE_PROVIDER_PATHS"
                        android:resource="@xml/file_paths" />
                </provider>
            </application>

In Eclipse in Project properties -> Java Build Path -> Order and Export selected: Android Private libraries and Android Dependencies. android-support-v4.jar is inside project's libs folder.

FREFunction code excerpt:

package com.test.OpenWithDefaultApp.functions;

.....

import android.content.Intent;
import android.net.Uri;
import android.support.v4.content.FileProvider;

.....

Uri contentUri = FileProvider.getUriForFile(context.getActivity(), "com.test.OpemWithDefaultApp.fileprovider", file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(contentUri, fileType);

.....

context.getActivity().startActivity(intent);

.....

I'm using

Eclipse Luna 4.4.0
Eclipse Android Plugin 23.0.3
Android SDK Tools 23.0.2
Android SDK Platform-tools 20
Android SDK Build-tools 20
Android SDK from 14 upto 20
Android Support Library 20
Google Play services 19

Native extension structure:

+android
      -libs/android-support-v4.jar
      -res/xml/file_paths
      -library.swf
      -openwithdefaultapp.jar
+default
      -library.swf
-extension.xml

But I'm stuck with error:

java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/air.testFileProvider-2.apk"],nativeLibraryDirectories=[/data/app-lib/air.testFileProvider-2, /vendor/lib, /system/lib]]

Any help would be appreciated. Thanks

Wormeaten answered 13/8, 2014 at 16:23 Comment(6)
Have you seen #9085689 or forums.adobe.com/message/4806229? This sounds like the same root issue.Calvo
Thanks Brian! yozhik answer on https://mcmap.net/q/1919723/-how-to-add-third-party-jar-files-into-my-android-application-jar-file solved my problem. The only thing I don't like is the new size of my jar (700kb insted of 10kb) but at least it works! Thanks!Wormeaten
This problem was happening to your because the generated AndroidManifest.xml was including tags for which your jar file had no dependencies (i.e.**android.support.v4.content.FileProvider**).Selfaddressed
@IgorGanapolsky, how to fix this?Terbecki
@Terbecki You need to find out which Google/Android apis you need in your project, and construct your build.gradle file accordingly. Or include the hard-coded jars in the /lib folder if you wish.Selfaddressed
@IgorGanapolsky, Thanks Igor, lastly, I solved it by cleaning up my build folder and it compiled again.Terbecki
R
0

android:authorities="com.test.fileprovider" and "com.test.OpemWithDefaultApp.fileprovider", both these names should be same

Rookie answered 7/9, 2017 at 10:20 Comment(0)
F
0

in AndroidManifest.xml

change

<provider android:name="android.support.v4.content.FileProvider"

to

<provider android:name="androidx.core.content.FileProvider"

tested and works for me

Falchion answered 9/5, 2021 at 18:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.