Robolectric、Android Studio、およびGradleの最新バージョンを実行しています。ユニットテストを統合してアプリを実行する際のコンパイルの問題を避けるためにAndroid Studioプロジェクトを構成するには
私がRobolectricのテストケースを作成して以来、タイトルが示唆しているように、私はアプリに戻ってアンドロイドアプリを以前と同じようにコンパイルするのに苦労しています。
私はアプリを実行しようとするたびに、私は以下のコンパイルエラーを取得:ここ
Error:(35, 23) error: package org.robolectric does not exist
Error:(36, 23) error: package org.robolectric does not exist
Error:(37, 34) error: package org.robolectric.annotation does not exist
Error:(38, 42) error: package org.robolectric.shadows.httpclient does not exist
Error:(44, 2) error: cannot find symbol class Config
Error:(43, 10) error: cannot find symbol class RobolectricTestRunner
Error:(197, 13) error: cannot find symbol variable FakeHttp
Error:(198, 13) error: cannot find symbol variable FakeHttp
Error:(218, 9) error: cannot find symbol variable FakeHttp
Error:(238, 25) error: cannot find symbol variable Robolectric
Error:(250, 25) error: cannot find symbol variable Robolectric
Error:(260, 25) error: cannot find symbol variable Robolectric
Error:(263, 28) error: cannot find symbol variable Robolectric
Error:(275, 38) error: cannot find symbol variable Robolectric
Error:(291, 25) error: cannot find symbol variable Robolectric
Error:(294, 28) error: cannot find symbol variable Robolectric
Error:(305, 32) error: cannot find symbol variable Robolectric
Error:(317, 25) error: cannot find symbol variable Robolectric
は私のGradleファイルです:現在のファイル構造については
sourceSets{
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
java.exclude {'src/test'}
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
test {
java.srcDirs = ['src/test/java']
}
// 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')
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile('com.facebook.android:facebook-android-sdk:[email protected]') {
exclude module: 'support-v4'
}
compile files('libs/universal-image-loader-1.9.5.jar')
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true;
}
compile files('libs/KochavaSDK.jar')
compile files('libs/Parse-1.9.1.jar')
compile files('libs/picasso-2.4.0.jar')
compile files('libs/adobeMobileLibrary-4.11.0.jar')
compile project(':cardview')
compile project(':CropImage')
compile project(':MapboxAndroidSDKNew')
compile project(':android-pdfview')
compile project(':UserVoiceSDK')
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.+'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v13:23.0.1'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.1.2'
testCompile 'org.robolectric:shadows-multidex:3.1.2'
testCompile 'org.robolectric:shadows-httpclient:3.1.2'
}
、私が設定していますこれらのコンパイルの問題を引き起こしていたsrcフォルダの下のtestとcom.example.applicationフォルダ
この修正には、メインのソースセットの下に 'java {exclude' src/test '}'を使用してテストフォルダを除外することがいくつか回避されていますが、うまくいくようです。私はまた、 'org.robolectric:robolectric:3.1.2'と他のrobolectricライブラリのコンパイルを追加しようとしましたが、あまりにも煩わしいので、このプロジェクトを適切な場所に設定する必要があります。
ご迷惑をおかけしますが、何卒ご了承ください。
編集:この質問をもう少し書き直してください。
あなたの質問をより具体的にしてください。つまり、プロジェクトを避けて、問題1、問題2、問題3をどうやって構造化すればよいのでしょうか。 – kyle
あなたのアプリはどこにありますか? –
@kyle私はちょっと私の質問に言い直しました。それはよりよいはずです –