我想运行我的第一个React本机项目,我使用linux,我想运行android项目。
我安装了最新版本的android studio并安装了android SDK,并在shell配置中导出了PATH。
我使用react-native init albums
创建了项目,并使用android studio打开了albums/android
,android studio自动安装gradle并没有出错。
我用android 4.0.3创建一个AVD并运行它。
我想使用react-native run-android
运行我的项目,但出现错误:
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
:app:checkDebugClasspath UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:mainApkListPersistenceDebug UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:copyDebugBundledJs SKIPPED
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:checkDebugLibraries UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug UP-TO-DATE
:app:packageDebug UP-TO-DATE
:app:installDebug
Skipping device 'Nexus_5X_API_15(AVD) - 4.0.4' for 'app:debug': minSdkVersion [16] > deviceApiLevel [15]
:app:installDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> Failed to install on any devices.
* 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 6s
28 actionable tasks: 1 executed, 27 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
我如何解决此错误?
答案 0 :(得分:2)
问题在于您的应用程序的目标是Android的16 API级别,并且您试图在一个较小的API中运行它(15)。尝试更改清单中的API级别,但是,如果您想运行React Native Apps,我认为较小的Android API是16。
答案 1 :(得分:1)
答案 2 :(得分:0)
将以下方法添加到build.gradle中(在allprojects方法之前)
子项目{ project.configurations.all { resolutionStrategy.eachDependency {详细信息-> 如果(details.requested.group =='com.android.support' &&!details.requested.name.contains('multidex')){ details.useVersion“ 28.0.0” } } } }
在package.json中将您的React本机版本更改为0.57.3
开心吧