作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试关注 this tutorial整合MFP 7.1 SDK
进入原生安卓应用程序。该应用程序是使用最新的 Studio 1.5.1
构建的. MFP android 原生 API 组件部署在我的开发服务器上。出于测试目的,我将原生 API 上的应用程序访问设置为“Activity ,通知”,因为我希望看到弹出窗口出现在 Android 应用程序中。当我调用 WLClient
连接来自 Java
的调用代码,我看到以下class cast exception
.应用程序不会崩溃,但是我没有看到 Activity 的通知对话框/弹出窗口。
02-05 01:57:07.010 2992-2992/com.ibm.test.myapplication I/art: Not late-enabling -Xcheck:jni (already on)
02-05 01:57:07.130 2992-3011/com.ibm.test.myapplication W/com.worklight.common.Logger: com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture. Currently, the 'capture' flag is set but the 'context' field is not. This warning will only be printed once.
02-05 01:57:07.130 2992-3011/com.ibm.test.myapplication D/wl.request: WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://192.168.1.3:10080/MFPNativeApps/authorization/v1/clients/instance
02-05 01:57:07.130 2992-3011/com.ibm.test.myapplication D/WLClient: WLClient$ActivityListener.onActivityStarted in WLClient.java:1476 :: on activity started com.ibm.test.myapplication.MainActivity
02-05 01:57:07.130 2992-3011/com.ibm.test.myapplication D/WLClient: WLClient$ActivityListener.onActivityResumed in WLClient.java:1465 :: on activity resumed com.ibm.test.myapplication.MainActivity . activity count = 1
02-05 01:57:07.130 2992-3013/com.ibm.test.myapplication D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: java.lang.ClassCastException: com.worklight.wlclient.WLPersistentCookieStore cannot be cast to org.apache.http.client.CookieStore
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:93)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:295)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:413)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java:47)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-05 01:57:07.140 2992-3012/com.ibm.test.myapplication W/System.err: at java.lang.Thread.run(Thread.java:818)
02-05 01:57:07.150 2992-3011/com.ibm.test.myapplication D/wl.certManager: WLCertManager.clearKeystore in WLCertManager.java:258 :: Key store cleared.
02-05 01:57:07.200 2992-3013/com.ibm.test.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
02-05 01:57:07.220 2992-3013/com.ibm.test.myapplication D/OpenGLRenderer: Enabling debug mode 0
02-05 01:57:07.220 2992-3013/com.ibm.test.myapplication W/EGL_emulation: eglSurfaceAttrib not implemented
02-05 01:57:07.220 2992-3013/com.ibm.test.myapplication W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3fd8e60, error=EGL_SUCCESS
apply plugin: 'com.android.application'
repositories{
jcenter()
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.ibm.test.myapplication"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/ASL2.0'
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/NOTICE'
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.ibm.mobile.foundation:ibmmobilefirstplatformfoundation:7.1.5@aar'
}
package com.ibm.test.myapplication;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import com.worklight.wlclient.api.WLClient;
import com.worklight.wlclient.api.WLFailResponse;
import com.worklight.wlclient.api.WLResponse;
import com.worklight.wlclient.api.WLResponseListener;
public class MainActivity extends AppCompatActivity implements WLResponseListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
WLClient.createInstance(this).connect(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onSuccess(WLResponse var1) {}
public void onFailure(WLFailResponse var1) {}
}
最佳答案
我想我找到了答案。这是 gradle 文件中的一个愚蠢的错误。我必须使用以下 loopj 版本:compile 'com.loopj.android:android-async-http:1.4.8'
.对于再次遇到此问题的人,我已在教程中添加了评论。
关于Android Studio ClassCastException : com. worklight.wlclient.WLPersistentCookieStore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35218264/
我正在尝试关注 this tutorial整合MFP 7.1 SDK进入原生安卓应用程序。该应用程序是使用最新的 Studio 1.5.1 构建的. MFP android 原生 API 组件部署在我
我是一名优秀的程序员,十分优秀!