react-native-file-selector
react-native-file-selector copied to clipboard
Problem with installation
Hi @prscX ,
I'm trying to install the module.
But I'm having some problems.
I created the file res / values / color.xml
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://maven.google.com" }
}
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://maven.google.com" }
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.playervideo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://maven.google.com" }
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://maven.google.com" }
}
}
dependencies {
compile project(':react-native-file-selector')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
log
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-file-selector
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.design.widget.CoordinatorLayout$Behavior
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder
\debug\119.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\120.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\i
ntermediates\transforms\dexBuilder\debug\121.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\122.jar, C:\Users\pc\Desktop\m
mm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\123.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug
\124.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\125.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\interme
diates\transforms\dexBuilder\debug\126.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\127.jar, C:\Users\pc\Desktop\mmm\pla
yervideo\android\app\build\intermediates\transforms\dexBuilder\debug\128.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\129.j
ar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\130.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates
\transforms\dexBuilder\debug\131.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\132.jar, C:\Users\pc\Desktop\mmm\playervid
eo\android\app\build\intermediates\transforms\dexBuilder\debug\133.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\134.jar, C:
\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\135.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\trans
forms\dexBuilder\debug\136.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\137.jar, C:\Users\pc\Desktop\mmm\playervideo\and
roid\app\build\intermediates\transforms\dexBuilder\debug\138.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\139.jar, C:\Users
\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\140.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\
dexBuilder\debug\141.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\142.jar, C:\Users\pc\Desktop\mmm\playervideo\android\a
pp\build\intermediates\transforms\dexBuilder\debug\143.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\144.jar, C:\Users\pc
\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\145.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBui
lder\debug\146.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\147.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\bui
ld\intermediates\transforms\dexBuilder\debug\148.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\152.jar, C:\Users\pc\Deskt
op\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\156.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\d
ebug\160.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\164.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\int
ermediates\transforms\dexBuilder\debug\168.jar, C:\Users\pc\Desktop\mmm\playervideo\android\app\build\intermediates\transforms\dexBuilder\debug\172.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
36 actionable tasks: 1 executed, 35 up-to-date
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
Same here, installation fails:
> > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
> D8: Program type already present: android.support.design.widget.CoordinatorLayout$Behavior
>
>
> FAILURE: Build failed with an exception.
>
> * What went wrong:
> Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
@386sx @AibiTi @Angelk90
I had the same problem and I don't know why ( and i don't want to know why)
But after i added this line to ./android/app/build.gradle
It got fixed:
implementation 'com.android.support:design:27.1.0'
Hope it helps you.
@386sx But when open the component and after allow permissions app will close without any warning
Hello, I could get it working. So far I've just tested on Android, this is what I have:
_openFileChooser = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
{
title: 'Title',
message: ' Access your files',
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
RNFileSelector.Show({
title: 'Select File',
onDone: path => {
alert(path);
this.props.navigation.navigate('LoanUploadPreview');
},
onCancel: () => {
alert('cancelled');
},
});
}
} catch (e) {
console.log(e);
}
};
In android/app/build.gradle
(part of it)
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
}
dependencies {
implementation project(':react-native-file-selector')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:design:27.1.1'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile 'com.android.support:support-v4:27.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
}
In colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#000000</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
I also added <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
in my AndroidManifest but I'm not sure if that is actually needed.
I hope this helps, thank u!
@386sx But when open the component and after allow permissions app will close without any warning
Did you manage to fix it? I'm having same issue
@386sx But when open the component and after allow permissions app will close without any warning
Did you manage to fix it? I'm having same issue
use this <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@shrolr
Thanks to @cybercoder @ricbermo I fixed the issue following cybercoder comment and ricbermo comment. To resume:
- I added this line
implementation 'com.android.support:design:27.1.1'
in./android/app/build.gradle
Sobuild.gradle
looks like:
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
}
dependencies {
implementation project(':react-native-file-selector')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:design:27.1.1'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile 'com.android.support:support-v4:27.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
}
- In
android/app/src/main/res/values
I createdcolors.xml
file.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#000000</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
- And added permission
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
inAndroidManifest
Thanks to @cybercoder @ricbermo I fixed the issue following cybercoder comment and ricbermo comment. To resume:
- I added this line
implementation 'com.android.support:design:27.1.1'
in./android/app/build.gradle
Sobuild.gradle
looks like:repositories { maven { url "http://dl.bintray.com/lukaville/maven" } } dependencies { implementation project(':react-native-file-selector') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'com.android.support:design:27.1.1' implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" compile 'com.android.support:support-v4:27.0.2' implementation "com.facebook.react:react-native:+" // From node_modules }
- In
android/app/src/main/res/values
I createdcolors.xml
file.<?xml version="1.0" encoding="utf-8"?> <resources> <color name="primary_dark">#000000</color> <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> </resources>
- And added permission
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
inAndroidManifest
I did what has been mentioned, still getting same error
I getting on your step, but still had same error.