react-native-file-selector
react-native-file-selector copied to clipboard
Build Failed
Hi there, I'm very new to React Native and I'm facing some issues in installing this lib. I have installed the library and then linked it. After running the command react-native run-android, I am getting this error :
Please help me to resolve it. Thanks in advance.
I have updated gradle version, changed sdk version in android\app\build.gradle and added maven dependencies in android\build.gradle
android\app\build.gradle
android { compileSdkVersion 27 <- buildToolsVersion "27.0.3" <-
defaultConfig { ....... targetSdkVersion 27 <-
dependencies { .......... compile 'com.android.support:appcompat-v7:27.0.2' <- compile 'com.android.support:support-v4:27.0.2' <- }
android\build.gradle allprojects { repositories { ............ maven { url "http://dl.bintray.com/lukaville/maven" } } }
Now the build is successful but app is crashing when I am adding file selector code. I don't know the root cause.
Thanks @shubham-srivastava-goku for raising the issue. Have you configured below step:
- Add below color attributes in your app res/color.xml. You can provide your own color codes
#3F51B5 #303F9F #FF4081
Thanks </ Pranav >
@prscX , from where I can get this xml file. There should be a predefined file for this project I guess.
@shubham-srivastava-goku: Basically in your android app, you need to create a resource file res/color.xml
if it does not exist. Please refer example app for the same.
Please let me know in case you still face the same issue.
Thanks </ Pranav >
@shubham-srivastava-goku you helped me get further in the build, but it still fails for me
$ react-native run-android
...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not find com.android.support:appcompat-v7:27.0.2.
Searched in the following locations:
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
file:/home/j/_Github-Projects/CentralComicReader/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
Required by:
CentralComicReader:app:unspecified
> Could not find com.nbsp:library:1.8.
Searched in the following locations:
file:/home/j/Android/Sdk/extras/android/m2repository/com/nbsp/library/1.8/library-1.8.pom
file:/home/j/Android/Sdk/extras/android/m2repository/com/nbsp/library/1.8/library-1.8.jar
file:/home/j/_Github-Projects/CentralComicReader/android/sdk-manager/com/nbsp/library/1.8/library-1.8.jar
Required by:
CentralComicReader:app:unspecified > CentralComicReader:react-native-file-selector:unspecified
> Could not find com.android.support:appcompat-v7:27.0.2.
Searched in the following locations:
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
file:/home/j/_Github-Projects/CentralComicReader/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
Required by:
CentralComicReader:app:unspecified > CentralComicReader:react-native-file-selector:unspecified
> Could not find com.android.support:support-v4:27.0.2.
Searched in the following locations:
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.pom
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
file:/home/j/_Github-Projects/CentralComicReader/android/sdk-manager/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar
Required by:
CentralComicReader:app:unspecified > CentralComicReader:react-native-file-selector:unspecified
> Could not find com.android.support:appcompat-v7:27.0.2.
Searched in the following locations:
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
file:/home/j/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
file:/home/j/_Github-Projects/CentralComicReader/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
Required by:
CentralComicReader:app:unspecified > com.facebook.react:react-native:0.55.4
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 56.024 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Found my solution here https://github.com/react-native-community/react-native-svg/issues/584
had to change this line in the file $myProject/android/gradle/wrapper/gradle-wrapper.properties
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
I was using gradle 2.x for whatever reason by default
Other tips for others having build issues: read through the config files (at least build.gradle and app/build.gradle) in the Example
folder in the root of this repo
@jtara1 , hi, I've updated gradle version. Now the app is building but now the runtime error is coming and app is crashing.
FATAL EXCEPTION: main
Process: com.fileexp, PID: 7162
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fileexp/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f03005f a=1240 r=0x7f050028}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2875)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2950)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6750)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f03005f a=1240 r=0x7f050028}
at android.content.res.TypedArray.getColor(TypedArray.java:469)
at android.app.Activity.onApplyThemeResource(Activity.java:4267)
at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java:199)
at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java:141)
at android.app.Activity.setTheme(Activity.java:4245)
at android.support.v7.app.AppCompatActivity.setTheme(AppCompatActivity.java:89)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2821)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2950)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6750)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Are you getting any errors after updating gradle version.
@shubham-srivastava-goku I wasn't getting any runtime errors, but the entire app just crashed when I called RNFileSelector.Show
using the example usage code. I'm guessing my issue here was that I'm using android 5.1, but this requires android API 27+ (?).
I was having the same problem with another lib, react-native-document-picker
or was it file picker? I haven't tried newer versions of android, but one claimed supp for android 1.0+ :/
Same error here.
@ronastlelobo use react-native-document-picker. It is working fine for me.
I am using react-native-document-picker itself. But I am unable to get the absolute path of the file. I am getting "content://com.android.........../document./....", my expectation is "filepath://SDCARD/documents/.......". So I was testing out this library.
@ronastlelobo you got any solutions ?
@shubham-srivastava-goku follow this link Solution and follow my first comment in this link of how i used it Usage Example