在一项活动中,我有2个按钮,可以生成警报对话框: 首先,我有以下功能,它非常好:
builder.setPositiveButton("Oui", new DialogInterface.OnClickListener(){
@override
public void onClick(DialogInterface dialof,int which){
broadcastOptServ("clear","clear");
}
});
我想要第二个类似的结构,但是如果我做的话,grable让我失败:
builder.setPositiveButton("Oui", new DialogInterface.OnClickListener(){
@override
public void onClick(DialogInterface dialof,int which){
broadcastOptServ("Ack","Ack");
}
});
这样就可以了:
builder.setPositiveButton("Oui", new DialogInterface.OnClickListener(){
@override
public void onClick(DialogInterface dialof,int which){
new Thread(new runnable(){
@override
public void run(){
broadcastOptServ("Ack","Ack");
}
}).start();
}
});
为什么grable不喜欢第一个结构? 它的错误是:
FAILURE : Build failed with an exception.
*What went wrong
Execution failed for task ':app:dexDebug'.
com.android.ide.internal.LoggedErrorException: Failed to run command:
C:\....\sdk\build-tools\21.1.2\dx.bat --dex -- incremental --no-strict --output
C:\....\build\intermediates\dex\debug --input-list = C:\...\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION
com.android.dex.DexException: Multiple dex files define Lcom/ibm/mqtt/IMqttClient
com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
com.android.dx.command.dexer.Main.run(Main.java:246)
com.android.dx.command.dexer.Main.main(Main.java:215)
com.android.dx.command.Main.main(Main.java:106)
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 10
buildToolsVersion "21.1.2"
defaultConfig {
applicationId 'org.mosquitto.android.SupTel'
targetSdkVersion 10
minSdkVersion 10
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
debuggable true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
dexOptions {
incremental true
//preDexLibraries =false
}
}
dependencies {
compile files('ia92/J2SE/wmqtt.jar')
}
我还有另外一个问题:当我尝试使用按钮" Ack"时,广播永远不会发送......为什么? (在更新Android Studio之前,所有这一切都很好 - ')
感谢时间;)
抱歉我的英文......