代码之家  ›  专栏  ›  技术社区  ›  Masoud92m

反应原生运行android有错误,如何修复?

  •  0
  • Masoud92m  · 技术社区  · 6 年前

    我想运行我的第一个react原生项目,我使用linux,我想运行android项目。 我用创建项目 react-native init albums 打开 albums/android 使用androidstudio,androidstudio自动安装gradle并且没有错误。 我想用它来运行我的项目 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
    

    如何修复此错误?

    2 回复  |  直到 6 年前
        1
  •  2
  •   SmoggeR_js    6 年前

    问题是你的应用程序的目标是Android的16 API级别,而你正试图在一个较小的API(15)中运行它。尝试更改清单中的API级别,但是如果您想运行React本机应用程序,我认为较小的Android API是16。

        2
  •  1
  •   luissmg    6 年前

    根据 this 页码:

    Supported target operating systems are >= Android 4.1 (API 16) ...

        3
  •  0
  •   Ederson JR    5 年前
    1. 将以下方法添加到build.gradle中(在allprojects方法之前)

      子项目{ 项目.configurations.all{ if(details.requested.group=='com.android.support' &&!details.requested.name.contains('multidex')){ details.useVersion“28.0.0” } } }

    2. 将package.json中的react本机版本更改为0.57.3

    3. 而且要快乐