2015-01-29 2 views
2

우선, 저는 Android and ndk에 대한 경험이 많지만, gradle 스크립트는 새로운 주제라고 인정해야합니다. 나는 gradled 스크립트가 이미 작성된 프로젝트에 참여하고 있습니다. (제 부분이 아닙니다.) 잘 작동합니다.Gradle task가 local.properties 파일을 찾을 수 없습니다.

내 문제는 특정 작업이 local.properties 파일에 정의 된 속성 정의 ndk.dir을 찾지 못하는 것입니다.

은 프로젝트 구조 (간체)한다 :의 build.gradle 파일에 정의

ndk.dir=/home/ubuntu/dev/android-ndk-r9c 

그리고 작업의 문제 부분 :

_ <project_root> 
|_ <sub_project folder> 
    ... 
    |_ main 
    |_ build.gradle 
    |_ local.properties 
|_ ... 

local.properties 파일처럼 보인다 구조는 다음과 같습니다.

task buildNDKFlavorGooglePlayStore(type: Exec) { 
    if (project.ext.has('ndk.dir') && (project.ext.get('ndk.dir') != null)) { 
     ext.ndkBuild = new File((String)project.ext.get('ndk.dir'), 'ndk-build') 
     executable ndkBuild 
    } else { 
     throw new GradleException('Reason: ndk.dir is missing in ' + projectDir + '/local.properties') 
    } 
(...) 
} 

프로젝트를 동기화 할 때 gr adle 예외가 정의되었습니다.

아무도 도와 줄 수 있습니까? 디버깅이 가능한지 알려주시겠습니까?

미리 감사드립니다. 필요한 경우 주저하지 말고 추가 정보를 요청하십시오.

+0

'local.properties' 대신에'gradle.properties'를 사용해 보셨나요? –

답변

7

이것은 나를 위해 작동 : 자세한 내용은

def getNdkDir() { 
    if (System.env.ANDROID_NDK_ROOT != null) 
     return System.env.ANDROID_NDK_ROOT 

    Properties properties = new Properties() 
    properties.load(project.rootProject.file('local.properties').newDataInputStream()) 
    def ndkdir = properties.getProperty('ndk.dir', null) 
    if (ndkdir == null) 
     throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.") 

    return ndkdir 
} 

def getNdkBuildCmd() { 
    def ndkbuild = getNdkDir() + "/ndk-build" 
    if (Os.isFamily(Os.FAMILY_WINDOWS)) 
     ndkbuild += ".cmd" 

    return ndkbuild 
} 

here합니다.

관련 문제