Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓工作室+;安卓&x2B;React-Native:找不到support-v4.jar_Android_Android Studio_React Native_React Native Android_Android Sdk Manager - Fatal编程技术网

Android 安卓工作室+;安卓&x2B;React-Native:找不到support-v4.jar

Android 安卓工作室+;安卓&x2B;React-Native:找不到support-v4.jar,android,android-studio,react-native,react-native-android,android-sdk-manager,Android,Android Studio,React Native,React Native Android,Android Sdk Manager,我试图在模拟器中运行我的React本机应用程序 我按照React Native的说明进行了操作,最后得到了他们建议的配置: 接下来,我启动了虚拟设备并运行了react native run android。此操作失败,因为我使用了React Native Keychain。但是我发现了一个github问题,并且 然后我又运行了react native run android,但现在我有一个不同的错误。以下是错误消息: JS server already running. Building an

我试图在模拟器中运行我的React本机应用程序

我按照React Native的说明进行了操作,最后得到了他们建议的配置:

接下来,我启动了虚拟设备并运行了
react native run android
。此操作失败,因为我使用了React Native Keychain。但是我发现了一个github问题,并且

然后我又运行了
react native run android
,但现在我有一个不同的错误。以下是错误消息:

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/jan/Library/Android/sdk/ndk-bu
ndle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/jan/Library/Android/sdk/ndk-bu
ndle.

If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Module 'com.android.support:support-v4:26.1.0' depends on one or more Android Libraries but is a jar

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-keychain'.
      > Could not find support-v4.jar (com.android.support:support-v4:26.1.0).
        Searched in the following locations:
            https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
正如您所看到的,有两个错误。第一个涉及某种NDK,第二个涉及support-v4.jar。我觉得两者都是随机的。让我解释一下

关于第一个错误,我查看了我的
local.properties
文件。我没有指定ndk.dir。这是我的整个
local.properties
文件:

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Jul 11 09:11:54 CEST 2018
sdk.dir=/Users/jan/Library/Android/sdk
关于支持版本的第二个错误同样奇怪。我使用Android Studio打开了该项目,下面是所说的:

我检查了我的SDK管理器,果然,支持存储库已完全安装

我被卡住了。如何修复这些错误

编辑:我能够使用线程“修复”NDK错误。最后一个问题仍然存在:(

Edit2:根据评论中的要求,这里是构建等级:

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.ordersome"
        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
            }
        }
    }
}

dependencies {
    compile project(':react-native-fbsdk')
    compile project(':react-native-keychain')
    compile project(':react-native-config')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "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'
}

试试这个,很好!非常感谢,速度太快了。现在我遇到了下一个错误:(
error:error:找不到与给定名称匹配的资源:attr'android:keyboardNavigationCluster.
请尝试更新gradle文件中的compileSdkVersion和buildtool你是指这些吗?
buildToolsVersion=“26.0.3”minSdkVersion=16编译器dkVersion=26
?它们应该是哪个版本/我如何升级它们?(顺便说一句,Huuugge谢谢你的帮助!)你能更新你的帖子并添加你的构建梯度文件吗?