我试图在我的项目中使用Android Skype SDK示例代码,但我收到一个错误消息,称无法执行方法OnClick。SkypeActivity。类不能强制转换为S4BDEMOA应用程序。类
。
我猜这是我S4BDEMOA应用程序中的部分代码。课程:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
行MultiDex.install(this)
可能会导致问题,因为我没有在我的gradle中包含任何dexOptions
。
我确实有它们,但当我试着运行它时,我得到了一个错误:
没有这样的属性,所以我不得不在gradle中对它们进行注释,效果很好。
你认为这就是错误的原因吗?有解决办法吗?
我的gradle档案
apply plugin: 'com.android.application'
def ROOTDIR = file("..").absolutePath
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "it.moondroid.chatbot"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
debug {
minifyEnabled false
debuggable true
jniDebuggable true
}
release {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/MSFTSIG.RSA'
exclude 'META-INF/BCKEY.DSA'
exclude 'META-INF/BCKEY.SF'
exclude 'META-INF/MSFTSIG.SF'
}
dexOptions {
// preDexLibraries=false
// jumboMode = true
// javaMaxHeapSize "4g"
}
}
configurations {
all*. exclude group: 'com.android.support', module: 'support-v4'
all*. exclude group: 'com.android.support', module: 'support-annotations'
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/sanmoku-0.0.5.jar')
compile files('libs/joda-time-2.1.jar')
compile(name: "libucmp", ext: 'aar')
compile(name: "platform", ext: 'aar')
compile(name: "injector", ext: 'aar')
compile(name: "SkypeForBusiness", ext: 'aar')
compile(name: "ucmp-enums", ext: 'aar')
compile(name: "TelemetryClient2", ext: 'aar')
compile(name: "TelemetryService", ext: 'aar')
compile(name: "android-database-sqlcipher", ext: 'aar')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
}
错误:
致命异常:主进程:it。月球机器人。chatbot,PID:20952主题:主题:{default=overlay:system,iconPack:system,fontPkg:system,com.android.systemui=overlay:system,com.android.systemui.navbar=overlay:system}java。lang.IllegalStateException:无法为android执行方法:onClick at android。看法查看$DeclaredOnClickListener。android上的onClick(View.java:4458)。看法看法android上的performClick(View.java:5204)。看法麦克利克。在android上运行(View.java:21158)。操作系统。汉德勒。android上的handleCallback(Handler.java:739)。操作系统。汉德勒。android上的dispatchMessage(Handler.java:95)。操作系统。活套。android上的loop(Looper.java:148)。应用程序。活动线程。java上的main(ActivityThread.java:5461)。朗,反思一下。方法在com上调用(本机方法)。Android内部的操作系统。ZygoteInit$MethodandArgscaler。在com上运行(zyteinit.java:726)。Android内部的操作系统。合子体。main(zyteinit.java:616)由以下原因引起:java。朗,反思一下。java上的InvocationTargetException。朗,反思一下。方法在android上调用(本机方法)。看法查看$DeclaredOnClickListener。android上的onClick(View.java:4453)。看法看法performClick(View.java:5204)
SkypeActivity。JAVA
package it.moondroid.chatbot;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.TextView;
import com.microsoft.office.sfb.appsdk.AnonymousSession;
import com.microsoft.office.sfb.appsdk.Application;
import com.microsoft.office.sfb.appsdk.ConfigurationManager;
import com.microsoft.office.sfb.appsdk.Conversation;
import com.microsoft.office.sfb.appsdk.DevicesManager;
import com.microsoft.office.sfb.appsdk.Observable;
import com.microsoft.office.sfb.appsdk.SFBException;
import java.net.URI;
/**
* Main Activity of the app.
* The activity provides UI to join the meeting and navigate to the conversations view.
*/
public class SkypeActivity extends AppCompatActivity {
Application application = null;
ConfigurationManager configurationManager = null;
DevicesManager devicesManager = null;
ConversationPropertyChangeListener conversationPropertyChangeListener = null;
Conversation anonymousConversation = null;
AnonymousSession anonymousSession = null;
TextView conversationStateTextView = null;
Button joinMeetingButton = null;
private Intent conversationsIntent = null;
boolean meetingJoined = false;
/**
* Creating the activity initializes the SDK Application instance.
* @param savedInstanceState saved instance.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_skype);
this.application = Application.getInstance(this.getApplication().getApplicationContext());
this.devicesManager = application.getDevicesManager();
this.configurationManager = application.getConfigurationManager();
// This flag will enable certain features that are in preview mode.
// E.g. Audio / Video capability OnPrem topologies.
this.configurationManager.enablePreviewFeatures(true);
// Note that the sample enable video over cellular network. This is not the default.
this.configurationManager.setRequireWiFiForVideo(false);
// Max video channel count needs to be set to view video for more than one participant.
this.configurationManager.setMaxVideoChannelCount(5);
// Get UI elements.
this.conversationStateTextView = (TextView)findViewById(R.id.statusTextViewId);
this.joinMeetingButton = (Button)findViewById(R.id.joinMeetingButtonId);
this.conversationsIntent = new Intent(this,ConversationsActivity.class);
this.updateUiState();
}
@Override
protected void onDestroy() {
this.configurationManager = null;
this.application = null;
super.onDestroy();
}
/**
* Navigate to the conversations list view.
* Note that, the conversations list view is provided only for demonstration purposes.
* For anonymous meeting join it will always have a single conversation after meeting join is
* successful.
* @param view View
*/
public void onConversationsButtonClick(android.view.View view) {
this.navigateToConversationsActivity();
}
/**
* The click handler joins or leaves the meeting based on current state.
*
* @param view View.
*/
public void onJoinMeetingButtonClick(android.view.View view) {
// Hide keyboard
InputMethodHelper.hideSoftKeyBoard(this.getApplication().getApplicationContext(),
view.getWindowToken());
if (meetingJoined) {
// Leave the meeting.
try {
this.anonymousConversation.leave();
this.meetingJoined = false;
this.updateUiState();
} catch (SFBException e) {
e.printStackTrace();
}
} else {
//Join the meeting.
// Get the display name.
final android.widget.TextView displayNameTextView =
(android.widget.TextView) findViewById(R.id.displayNameEditTextId);
// Get the meeting uri
final android.widget.EditText joinMeetingEditText =
(android.widget.EditText) findViewById(R.id.meetingUriEditTextId);
String meetingUriString = joinMeetingEditText.getText().toString();
URI meetingUri = URI.create(meetingUriString);
// Join meeting and monitor conversation state to determine meeting join completion.
try {
// Set the default device to Speaker
//this.devicesManager.setActiveEndpoint(DevicesManager.Endpoint.LOUDSPEAKER);
this.anonymousSession = this.application.joinMeetingAnonymously(
displayNameTextView.getText().toString(), meetingUri);
this.anonymousConversation = this.anonymousSession.getConversation();
SFBDemoApplication application = (SFBDemoApplication)getApplication();
application.setAnonymousConversation(this.anonymousConversation);
// Conversation begins in Idle state. It will move from Idle->Establishing->InLobby/Established
// depending on meeting configuration.
// We will monitor property change notifications for State property.
// Once the conversation is Established, we will move to the next activity.
this.conversationPropertyChangeListener = new ConversationPropertyChangeListener();
this.anonymousConversation.addOnPropertyChangedCallback(this.conversationPropertyChangeListener);
} catch (SFBException e) {
e.printStackTrace();
}
}
}
/**
* Update the UI state.
*/
public void updateUiState() {
if (meetingJoined) {
this.joinMeetingButton.setText(R.string.leave_meeting);
} else {
this.joinMeetingButton.setText(R.string.join_meeting);
//conversationStateTextView.setText("");
}
}
/**
* Navigate to the Conversations activity.
*/
private void navigateToConversationsActivity() {
startActivity(this.conversationsIntent);
}
/**
* Determines meeting join state based on conversations state.
*/
public void updateConversationState() {
Conversation.State state = this.anonymousConversation.getState();
conversationStateTextView.setText(state.toString());
switch (state) {
case ESTABLISHED:
this.meetingJoined = true;
break;
case IDLE:
conversationStateTextView.setText("");
this.meetingJoined = false;
if (this.anonymousConversation != null) {
this.anonymousConversation.removeOnPropertyChangedCallback(this.conversationPropertyChangeListener);
this.anonymousConversation = null;
}
break;
default:
}
// Refresh the UI
this.updateUiState();
if (meetingJoined) {
this.navigateToConversationsActivity();
}
}
/**
* Helper method to show alerts.
* @param message Alert message.
*/
private void showAlert(String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message);
builder.show();
}
/**
* Callback implementation for listening for conversation property changes.
*/
class ConversationPropertyChangeListener extends Observable.OnPropertyChangedCallback {
/**
* onProperty changed will be called by the Observable instance on a property change.
*
* @param sender Observable instance.
* @param propertyId property that has changed.
*/
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
if (propertyId == Conversation.STATE_PROPERTY_ID) {
updateConversationState();
}
}
}
}
SFBDemoApplication。JAVA
package it.moondroid.chatbot;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import com.microsoft.office.sfb.appsdk.Conversation;
/**
* Demo Application class
*/
public class SFBDemoApplication extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
/**
* Saving the anonymous conversation to be shared across activities.
*/
private Conversation anonymousConversation = null;
/**
* Save the anonymous conversation.
* @param conversation
*/
public void setAnonymousConversation(Conversation conversation) {
this.anonymousConversation = conversation;
}
/**
* Get the anonymous conversation.
* @return Conversation conversation.
*/
public Conversation getAnonymousConversation() {
return this.anonymousConversation;
}
}
我想出来了。我没有更新AndroidManifest。xml
<application android:name='.SFBDemoApplication" >
问题内容: 任何人都可以解决此问题: Windows 10笔记本电脑上的SQL Server Management Studio 2016 CTP3(13.0.900.73) 对象资源管理器>服务器>数据库>数据库 右键单击-属性 我没有显示“数据库属性”对话框,而是显示了以下弹出窗口: 标题:Microsoft SQL Server Management Studio 无法显示请求的对话框。 附
我有一种方法,可以按照班级团队中的国家对数据库中的数据进行排序。Hibernate在列表中返回我的数据 我的错误日志: 我的冠军联赛课程: 我的班级: }
问题内容: 我有一个问题,我的应用生成了此异常,我听不懂。我已经在我的build.gradle中实现了multiDexEnabled 我的班级Java } 文件摇篮 Manifest.xml 问题答案: 我认为您应该将班级扩展到自己的班级,如下所示: 之后,您必须将文件更改为此: 请检查此链接以获取更多信息:http : //developer.android.com/reference/andr
问题内容: 从webservice(API)解码JSON时出现错误: 我的代码: 如果我将URL更改为http://localhost/fendy/getjson.php,它的工作原理很好。 如果我的网址是http://bitnami.local/cscart_demo/api/users,我会收到错误消息 来自网络服务http://localhost/fendy/getjson.php的响应:
所以,我试图建立一个报告。某些特定类型的用户的详细信息需要写在excel文件中。在到达endpoint时,它返回500,并使用以下StackTrace。 我希望将此模型用户配置文件的一些细节写入excel表中,并使其可供下载。你觉得我怎么解决这个问题。主要的错误来自这几行,特别是粗体字的那行
问题内容: 我是Java的新手,正在尝试理解为什么第一个代码片段不会导致此异常,而第二个代码片段会导致此异常。由于在两种情况下都将字符串数组传递到Arrays.asList中,所以两个代码片段都不应该产生异常还是不产生异常? 第一个代码段(毫无例外): 第二段(导致上述异常): 如果相关,我正在Eclipse Helios中使用JavaSE 1.6。 问题答案: 对我来说(使用Java 1.6.0