所以我正在尝试我们的Android Studio并测试一个在eclipse中工作的项目.我得到了所有编译,应用程序将启动就好了,但我不能让我的单元测试和工作.我最终通过添加我的应用程序lib文件夹作为依赖项来编译它们,但我不认为我的运行配置是正确的,因为无论何时我运行我的测试我都会收到此错误
Installing <packagename>
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/<packagename>"
pkg: /data/local/tmp/<packagename>
Success
Running tests
Test running started
Test running failed: Unable to find instrumentation info for: ComponentInfo{<packagename>/android.test.InstrumentationTestRunner}
Empty test suite.
Run Code Online (Sandbox Code Playgroud)
编辑:对于所有新来的人,自我最初发布此问题以来,Android Studio的状态发生了很大变化,但许多有用的人继续发布他们针对此错误的特定解决方案.我建议先主动排序并先查看最新的答案.
所以我有一个特征,我想传递并执行一些动态方法调度。我有一个方法需要特征作为装箱指针,但它需要调用另一个使用特征引用的方法。所以像:
trait Foo {
fn do_something(&self);
}
struct Bar;
impl Foo for Bar {
fn do_something(&self) {}
}
fn foo_as_box(foo : Box<Foo>) {
foo_as_ref(&foo);
}
fn foo_as_ref(foo : &Foo) {
foo.do_something();
}
fn main() {
let boxed_foo = box Bar as Box<Foo>;
foo_as_box(boxed_foo);
}
Run Code Online (Sandbox Code Playgroud)
但是,我在此代码上遇到错误
error: failed to find an implementation of trait Foo for Box Foo<no-bounds>
Run Code Online (Sandbox Code Playgroud) 我看到一些问题之间的兼容性com.google.android.gms:play-services-auth:11.6.0,并com.android.support.test.espresso:espresso-core:3.0.1
作为依赖使用的Android库模块上时
我收到这个错误:
Execution failed for task ':mylibrary:transformResourcesWithMergeJavaResForDebugAndroidTest'.
More than one file was found with OS independent path 'protobuf.meta'
Run Code Online (Sandbox Code Playgroud)
当我尝试执行时 ./gradlew :myLibrary:connectedAndroidTest
这是一个准确的build.gradle,我已经重现了这个问题:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Run Code Online (Sandbox Code Playgroud)
我不认为我可以排除这些文件中的任何一个,因为内容不同.
android protocol-buffers android-gradle-plugin android-espresso