
> AndroID Studio Gradle结构
> AndroID AppCompat库
> Robolectric进行测试
不涉及任何活动的测试(例如,断言1 == 1),工作正常.但是,当我使用activity时会产生以下错误:
java.lang.RuntimeException: huh? can't find parent for StyleData{name='theme_Sanactbar',parent='@style/theme_AppCompat_light_DarkActionbar'} at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getParent(ShadowAssetManager.java:365) at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getAttrValue(ShadowAssetManager.java:350) 我尝试了https://github.com/robolectric/robolectric/issues/979,但它创造了相同的结果.
供参考:
这是我的PROJECT / build.gradle
// top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositorIEs { mavenCentral() // For Robolectric maven { url 'https://oss.sonatype.org/content/repositorIEs/snapshots' } maven { url 'https://github.com/rockerhIEu/mvn-repo/raw/master/' } } dependencIEs { classpath 'com.androID.tools.build:gradle:0.11.+' classpath 'com.neenbedankt.gradle.plugins:androID-apt:1.2+' classpath 'org.robolectric.gradle:gradle-androID-test-plugin:0.10.1-SNAPSHOT' }}allprojects { repositorIEs { mavenCentral() // For Robolectric maven { url 'https://oss.sonatype.org/content/repositorIEs/snapshots' } }} 这是我的PROJECT / app / build.gradle
apply plugin: 'androID'apply plugin: 'androID-apt'apply plugin: 'androID-test' // RobolectricrepositorIEs { mavenLocal()}androID { compileSdkVersion 19 buildToolsversion "19.1.0" defaultConfig { applicationID "ID.web.michsan.helloworld" minSdkVersion 8 targetSdkVersion 19 versionCode 6 versionname "1.1.1" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } if (System.getenv("KEYSTORE") != null) { signingConfigs { release { storefile file(System.getenv("KEYSTORE")) storePassword System.getenv("KEYSTORE_PASSWORD") keyAlias System.getenv("KEY_AliAS") keyPassword System.getenv("KEY_PASSWORD") } } } buildTypes { release { runProguard false proguardfiles getDefaultProguardfile('proguard-androID.txt'),'proguard-rules.txt' if (System.getenv("KEYSTORE") != null) { signingConfig signingConfigs.release } } } /* For the sake of butterknife */ lintoptions { disable 'InvalIDPackage' } sourceSets { androIDTest.setRoot('src/test') // For Robolectric }}ext { androIDAPIVersion = '19.1.0' butterknifeVersion = '4.0.1' robotiumVersion = '5.0.1'}dependencIEs { compile 'com.androID.support:appcompat-v7:' + androIDAPIVersion compile 'com.androID.support:support-v4:' + androIDAPIVersion compile filetree(dir: 'libs',include: ['*.jar']) compile(project(':core')) { exclude group: 'org.apache.httpcomponents' exclude group: 'org.Json' } compile filetree(dir: '../core/libs',include: ['*.jar']) apt 'com.jakewharton:butterknife:' + butterknifeVersion compile 'com.jakewharton:butterknife:' + butterknifeVersion androIDTestCompile 'com.jayway.androID.robotium:robotium-solo:' + robotiumVersion // For Robolectric androIDTestCompile 'junit:junit:4.11' androIDTestCompile 'org.robolectric:robolectric:2.3' compile 'com.mopub.mobileads:mopub-androID:+@aar'}// Robolectric: Add this deFinition in order to only include files that are suffixed with Test.class and set the max heap sizeandroIDTest { include '**/*Test.class' maxHeapSize = "2048m"}解决方法 在调试Robolectric源之后,我知道我需要创建project.propertIEs文件. 假设您使用的是AndroID Studio项目结构,该文件的位置为PROJECT_X / app / src / main / project.propertIEs
内容是
androID.library.reference.1=/../../../build/intermediates/exploded-aar/com.androID.support/appcompat-v7/19.1.0
这是因为Robolectric的AndroIDManifest.getBaseDir()为你提供了/ path / into / AndroIDStudioProjects / PROJECT_X / app / src / main.
因此,此基本目录附加了引用位置.在这种情况下,我可以确保/ path / into / AndroIDStudioProjects / PROJECT_X / app / src / main /../../../build/intermediates/exploded-aar/com.androID.support/appcompat-v7/ 19.1.0给我一个包含appcompat库的AndroIDManifest.xml的目录.
总结以上是内存溢出为你收集整理的android-gradle – 在Android Studio和AppCompat中使用Robolectric时找不到StyleData的父级全部内容,希望文章能够帮你解决android-gradle – 在Android Studio和AppCompat中使用Robolectric时找不到StyleData的父级所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)