我是Java和Android Studio的新手,因为我主要在Xamarin下工作
我正在实施一个语音识别项目(最初是在Xamarin中开发的,但现在无法用于谷歌某处推出的大延迟)试图使用新的(仍然是beta)云语音识别。
我已经从here下载了一个样本并尝试使用它,但我遇到了一个奇怪的(对我而言)问题。 SpeechSettings对象使用ImmutableList来保存del default API范围,但是当ImmutableList add("something").build()
尝试调用checkNotNull函数时,我遇到了很多错误。我已经从SpeechSettings对象创建中提取了列表的创建,并且为了简单起见,我将它放在了Button的点击事件上。创建(或更好地,插入String元素)会导致相同的错误列表。
这是点击监听器的代码:
bRecon.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
try
{
ImmutableList<String> lTest = ImmutableList.String>builder().add("132").build();
}
catch (Exception ilEx)
{
}
SpeechRecon sr = new SpeechRecon();
});
}
这是创建ImmutableList时的相对LogCat输出:
11-24 13:26:03.007 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.ImmutableList.copyOf
11-24 13:26:03.007 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.007 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
11-24 13:26:03.017 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Joiner.appendTo, referenced from method com.google.common.collect.ImmutableCollection.toString
11-24 13:26:03.017 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve virtual method 26143: Lcom/google/common/base/Joiner;.appendTo (Ljava/lang/StringBuilder;Ljava/lang/Iterable;)Ljava/lang/StringBuilder;
11-24 13:26:03.017 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0013
11-24 13:26:03.022 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.ImmutableList$Builder.add
11-24 13:26:03.022 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.022 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0002
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkArgument, referenced from method com.google.common.collect.Lists.computeArrayListCapacity
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26164: Lcom/google/common/base/Preconditions;.checkArgument (Z)V
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0003
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.Lists.newArrayList
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.Lists.newArrayList
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.027 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.Lists.newArrayList
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava I/dalvikvm: Could not find method com.google.common.base.Preconditions.checkNotNull, referenced from method com.google.common.collect.Lists.partition
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to resolve static method 26168: Lcom/google/common/base/Preconditions;.checkNotNull (Ljava/lang/Object;)Ljava/lang/Object;
11-24 13:26:03.032 31057-31057/it.sia.cloudspeechrpcjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
11-24 13:26:03.037 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/google/common/base/Function;)
11-24 13:26:03.037 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/google/common/base/Function;)
11-24 13:26:03.042 31057-31057/it.sia.cloudspeechrpcjava W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/google/common/base/Function;)
这是我的gradle.build文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "it.sia.cloudspeechrpcjava"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1'
compile files('libs/guava-gwt-20.0.jar')
compile files('libs/guava-collections-r03.jar')
compile files('libs/gax-0.0.25.jar')
compile files('libs/grpc-all-1.0.1.jar')
compile files('libs/grpc-core-1.0.1.jar')
compile files('libs/grpc-core-proto-0.0.6.jar')
compile files('libs/grpc-google-cloud-speech-v1beta1-0.1.3.jar')
compile files('libs/joda-time-2.9.6.jar')
compile files('libs/protobuf-java-3.1.0.jar')
}
如果你们中的任何一个人能指出我可能的解决方案,那就太好了。 谢谢。 鲁道夫。
答案 0 :(得分:1)
guava-primitives
“Guava-Collections”已更新6年,并且取决于您尚未下载和包含的其他几个库。
Preconditions
被描述为“包含实用程序类的库”,因此它可能包含缺少的guava-collections
类。
将guava
替换为最新版本的{{1}}(20.0),它可能会有效。
我还建议学习自动依赖关系管理,因为手动下载库并确保这些库的依赖关系会很快变得非常混乱。