我最近想react-native
用相机创建一个应用程序并开始使用,react-native-camera
所以我这样做了:
$ react-native init testApp2
$ npm install --save react-native-camera
$ react-native link react-native-camera
$ react-native run-android
在最后一行之后,我得到了奇怪的输出(如下)(我的电脑上安装了 Android Studio,当我去构建 apk 时,Android Studio 会创建确切的错误)
Scanning folders for symlinks in C:\Users\seyye_000\Documents\testApp2\node_modules (31ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
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
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.2.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
:app:preBuild UP-TO-DATE
:react-native-camera:preBuild UP-TO-DATE
:react-native-camera:preDebugBuild UP-TO-DATE
:react-native-camera:checkDebugManifest UP-TO-DATE
:react-native-camera:processDebugManifest UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:react-native-camera:compileDebugAidl UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:react-native-camera:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:react-native-camera:mergeDebugShaders UP-TO-DATE
:react-native-camera:compileDebugShaders UP-TO-DATE
:react-native-camera:generateDebugAssets UP-TO-DATE
:react-native-camera:packageDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:react-native-camera:compileDebugRenderscript UP-TO-DATE
:react-native-camera:generateDebugResValues UP-TO-DATE
:react-native-camera:generateDebugResources UP-TO-DATE
:react-native-camera:packageDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:mainApkListPersistenceDebug UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:react-native-camera:platformAttrExtractor UP-TO-DATE
:react-native-camera:generateDebugRFile UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:react-native-camera:generateDebugBuildConfig UP-TO-DATE
:react-native-camera:prepareLintJar UP-TO-DATE
:react-native-camera:generateDebugSources UP-TO-DATE
:react-native-camera:javaPreCompileDebug UP-TO-DATE
:react-native-camera:compileDebugJavaWithJavac UP-TO-DATE
:react-native-camera:processDebugJavaRes NO-SOURCE
:react-native-camera:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebugD8: Program type already present: com.facebook.infer.annotation.FalseOnNull
FAILED
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\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\54.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\55.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\56.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\57.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\58.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\60.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\61.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\62.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\63.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\76.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\77.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\78.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\79.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\80.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\84.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\98.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\99.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\100.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\101.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\102.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\103.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\104.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\105.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\106.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\107.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\108.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\109.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\110.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\111.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\112.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\113.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\114.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\115.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\116.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\117.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\118.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\119.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\120.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\121.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\122.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\123.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\124.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\125.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\126.jar, C:\Users\seyye_000\Documents\testApp2\android\app\build\intermediates\transforms\dexBuilder\debug\127.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 21s
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
我已经尝试了所有可能的方式来使用 Android Studio 来修复这个错误,但我真的很累,不知道下一步该做什么。:\
这是我的package.json
:
{
"name": "testApp2",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-camera": "^1.1.3"
},
"devDependencies": {
"babel-jest": "22.4.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.4",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
如果你知道这有什么问题,请告诉我,我开始变得非常疯狂......
因为我不知道如何把我所有的代码放在这里,所以我只是把它上传到了 GitHub,这里是它的链接。