简体   繁体   English

Build.gradle无法规范文件路径

[英]Build.gradle Could Not normalize path for file

This happened in React Native when trying to build my app, but I feel like it is an all around gradle issue. 尝试构建我的应用时,这是在React Native中发生的,但是我觉得这是一个全面的问题。 Basically it seems like the path to the actual SDK is wrong.. I am running windows and have my path to the SDK stored in an "ANDROID_HOME" enviroment variable. 基本上看来,实际SDK的路径是错误的。我正在运行Windows,并将我的SDK路径存储在“ ANDROID_HOME”环境变量中。

* Where:
Build file 'D:\PackBar\android\app\build.gradle' line: 104

* What went wrong:
A problem occurred evaluating project ':app'.
Could not normalize path for file 'D:\PackBar\android\D:Android_SDK\tools\proguard\proguard-android.txt'.

For some reason it makes this the path: 'D:\\PackBar\\android\\D:Android_SDK\\tools\\proguard\\proguard-android.txt' 由于某种原因,它使该路径成为:'D:\\ PackBar \\ android \\ D:Android_SDK \\ tools \\ proguard \\ proguard-android.txt'

Obviously you can see the D:\\ twice.. clearly wrong.. the ACTUAL path to my sdk is: D:Android_SDK\\tools\\proguard\\proguard-android.txt' 显然,您可以看到两次D:\\ ..显然是错误的..我的SDK的实际路径是:D:Android_SDK \\ tools \\ proguard \\ proguard-android.txt'

I guess a simplified version of my question is how would I change this path? 我想我的问题的简化版本是如何更改此路径?

EDIT: HERE IS MY APP.GRADLE 编辑:这是我的APP.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,
 *
 *   // 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/**"]
 * ]
 */

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 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.packbar"
        minSdkVersion 16
        targetSdkVersion 22
        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 fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    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'
}

I was having the same issues and what fixed it for me was: 我遇到了同样的问题,对我来说解决的是:

My Environment: windows 10, 64 bit machine 我的环境:Windows 10、64位计算机

  1. I installed latest JDK. 我安装了最新的JDK。 (jdk-8u101-windows-x64) (Earlier I had 1.7 installed) (jdk-8u101-windows-x64)(之前安装了1.7)
  2. Added Environment variable JAVA_HOME= C:\\Program Files\\Java\\jdk1.8.0_101 (default path while installation in my case) 添加了环境变量JAVA_HOME = C:\\ Program Files \\ Java \\ jdk1.8.0_101(在我的情况下,安装时的默认路径)
  3. Added %JAVA_HOME%\\bin to PATH environment variable. 已将%JAVA_HOME%\\ bin添加到PATH环境变量中。
  4. started over with new project. 从新项目开始。 with react-native init newproj. 与反应本机init newproj。

I won't say it's an answer but please try if you haven't already. 我不会说这是答案,但是如果您还没有的话,请尝试。 I hope it helps. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM