2014-03-14 2 views
0
Android Studio 0.5.1 

내가 Gradle을 빌드 파일을 생성하여 내 이클립스 프로젝트 LocationLabLocationLabTest을 수출하고 있습니다.클래스는 테스트 패키지의 범위 내에 있지 않은

그런 다음 Android Studio로 가져 왔습니다. LocationLabTest에 대한 모듈 종속성은 Project Stucture의 LocationLab에 따라 달라 지므로이를 설정했습니다.

테스트해야하는 클래스가 테스트 패키지의 범위에 포함되지 않은 것으로 보입니다.

문제 LocationLabTest가 LocationLab 패키지 course.labs.locationlab LocationLabTest 매니페스트 파일에서

이 TargetPackage android:targetPackage="course.labs.locationlab"의 붉은 색을 가지고에 대한 가져 오기 패키지를 찾을 수 있다는 것입니다. 어떤 제안에 대한

많은 감사합니다, 여기에

내 구조의 스크린 샷입니다 : enter image description here

build.grade (LocationLabTest)

apply plugin: 'android' 

dependencies { 
    compile project(':LocationLab') 
    compile fileTree(dir: 'libs', include: '*.jar') 
} 

android { 
    compileSdkVersion 18 
    buildToolsVersion '19.0.1' 
    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
    buildTypes { 
    } 
} 

build.grade (LocationLab)

apply plugin: 'android' 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
} 

android { 
    compileSdkVersion 18 
    buildToolsVersion '19.0.1' 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 

답변

1

거들에서 테스트 테스트중인 코드와 별도의 모듈에 있지 않습니다. 테스트는 소스가 다른 디렉토리에있는 동일한 모듈에 있습니다. Gradle은 테스트 APK의 AndroidManifest.xml 파일을 자동으로 생성하므로 사용자가 지정하지 않습니다.

// Move the tests to tests/java, tests/res, etc... 
    instrumentTest.setRoot('tests') 

그래서 해당 폴더에 테스트 코드를 이동해야합니다 : 메인 모듈의 build.gradle 파일에서

, 당신은 이미 설정 테스트 폴더를 가지고있다. Gradle에서 시험 설정에 대한 설명서는 http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing

에 있습니다.
관련 문제