Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error migrating to AndroidX #49

Closed
SystemBlad opened this issue May 8, 2019 · 8 comments
Closed

Error migrating to AndroidX #49

SystemBlad opened this issue May 8, 2019 · 8 comments

Comments

@SystemBlad
Copy link

SystemBlad commented May 8, 2019

Hi,
I using this great library and I was trying to migrate my react native project to AndroidX but the following error is show:

Error:
package android.support.v4.content does not exist

In the file:
android\src\main\java\com\vinzscam\reactnativefileviewer\RNFileViewerModule.java

Line:
8

Do you know when I will be able to use this library with AndroidX?

Thanks.

@gla5001
Copy link

gla5001 commented May 17, 2019

I ran into this same issue. Opened up #50

@vinzscam
Copy link
Owner

AndroidX is not yet included in react-native projects. #50 includes many unnecessary files and it doesn't keep retro compatibility with current projects.

I would recommend to append the following snippet to your android/app/build.gradle file:

preBuild.doFirst {
    ant.replaceregexp(match:'android.support.v4.content.', replace:'androidx.core.content.', flags:'g', byline:true) {
        fileset(dir: '../../node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer', includes: '*.java')
    }
}

Let me know if that works.

@SystemBlad
Copy link
Author

AndroidX is not yet included in react-native projects. #50 includes many unnecessary files and it doesn't keep retro compatibility with current projects.

I would recommend to append the following snippet to your android/app/build.gradle file:

preBuild.doFirst {
    ant.replaceregexp(match:'android.support.v4.content.', replace:'androidx.core.content.', flags:'g', byline:true) {
        fileset(dir: '../../node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer', includes: '*.java')
    }
}

Let me know if that works.

@vinzscam is working using the snippet code thanks.

@gla5001
Copy link

gla5001 commented May 27, 2019

FWIW. The AndroidX migration stuff was merged into React Native. facebook/react-native#23112. It seems like its coming in 0.60.

@ws7one
Copy link

ws7one commented Sep 4, 2019

AndroidX is not yet included in react-native projects. #50 includes many unnecessary files and it doesn't keep retro compatibility with current projects.

I would recommend to append the following snippet to your android/app/build.gradle file:

preBuild.doFirst {
    ant.replaceregexp(match:'android.support.v4.content.', replace:'androidx.core.content.', flags:'g', byline:true) {
        fileset(dir: '../../node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer', includes: '*.java')
    }
}

Let me know if that works.

When I do this, in Android Studio, the project seems to build fine, but when i run react-native run-android, it gives me the same errors again

> Task :react-native-file-viewer:compileDebugJavaWithJavac FAILED
/Users/philip/Workspaces/clientbooks-mobile/node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer/FileProvider.java:3: error: package androidx.core.content does not exist
public class FileProvider extends androidx.core.content.FileProvider {
                                                       ^
/Users/philip/Workspaces/clientbooks-mobile/node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer/RNFileViewerModule.java:8: error: package androidx.core.content does not exist
import androidx.core.content.FileProvider;
                            ^
/Users/philip/Workspaces/clientbooks-mobile/node_modules/react-native-file-viewer/android/src/main/java/com/vinzscam/reactnativefileviewer/RNFileViewerModule.java:57: error: cannot find symbol
        contentUri = FileProvider.getUriForFile(getCurrentActivity(), authority, newFile);

@vauruk
Copy link

vauruk commented Oct 16, 2019

I have the same problem!

@ital0
Copy link

ital0 commented Oct 29, 2019

@ws7one @vauruk please take a look in this topic: #60

@Dhaval240420
Copy link

java.lang.RuntimeException: Unable to get provider com.vinzscam.reactnativefileviewer.FileProvider: java.lang.ClassNotFoundException: Didn't find class "com.vinzscam.reactnativefileviewer.FileProvider" on path: DexPathList[[zip file "/data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/base.apk"],nativeLibraryDirectories=[/data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/lib/arm, /data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6242)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
11-11 18:56:09.077 839 839 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-11 18:56:09.077 839 839 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
11-11 18:56:09.077 839 839 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
11-11 18:56:09.077 839 839 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.vinzscam.reactnativefileviewer.FileProvider" on path: DexPathList[[zip file "/data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/base.apk"],nativeLibraryDirectories=[/data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/lib/arm, /data/app/com.preventioncloud-31cbX744wihkDqzlqjvVKg==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
11-11 18:56:09.077 839 839 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
11-11 18:56:09.077 839 839 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
11-11 18:56:09.077 839 839 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
11-11 18:56:09.077 839 839 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6227)
11-11 18:56:09.077 839 839 E AndroidRuntime: ... 10 more
11-11 18:56:09.083 3287 17145 W ActivityManager: Force finishing activity com.preventioncloud/.MainActivity
11-11 18:56:09.089 3287 3378 I ActivityManager: Showing crash dialog for package com.preventioncloud u0

i am getting this type of runtime error after execute npx react-native run-android command app is successfully installed and crashed after splash screen and get these type of crash log any one can help me with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants