java.lang.ClassNotFoundException:在 Adone AIR 本机扩展中找不到类"android.support.v4.content.FileProvider"错误



也许我的问题听起来像以前被问过100次,但是相信我,我已经阅读了这100个类似问题的每个答案,没有一个能解决我的问题。所以我的本地扩展的目的是共享文档在我的应用程序缓存文件夹(doc, pdf等)与第三方应用程序(Quick Office, Adobe Reader等)。我发现FileProvider和intent可以解决我的问题。

我的应用描述文件包含:

<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>

在Eclipse中的Project properties -> Java Build Path -> Order and Export选择:Android私有库和Android依赖项。Android-support-v4.jar位于项目的lib文件夹中。

函数代码节选:

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);
.....

我使用

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

本地扩展结构:

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

但是我被错误卡住了:

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]]

任何帮助都会很感激。由于

android:authorities="com.test.fileprovider""com.test.OpemWithDefaultApp.fileprovider",这两个名称应该是相同的

in AndroidManifest.xml

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

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

相关内容

最新更新