我正在尝试通过 android studio 连接到 Object Storage 服务,但收到以下错误消息:
03-21 15:47:19.668 31335-31335/com.example.michaelwizard.coudapp I/System.out: VCAP_APPLICATION - null 03-21 15:47:19.668 31335-31335/com.example.michaelwizard.coudapp I/System .out: VCAP_SERVICES - null 03-21 15:47:19.688 31335-31335/com.example.michaelwizard.coudapp W/System.err: [org.openstack4j.core.transport.internal.HttpExecutor] 错误:未找到 OpenStack4j 连接器在类路径 03-21 15:47:19.689 31335-31335/com.example.michaelwizard.coudapp D/AndroidRuntime:关闭 VM 03-21 15:47:19.689 31335-31335/com.example.michaelwizard.coudapp E/AndroidRuntime :致命例外:主进程:com.example.michaelwizard.coudapp,PID:31335 org.openstack4j.api。exceptions.ConnectorNotFoundException:在 org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java: org.openstack4j.core.transport.internal.HttpExecutor.service(HttpExecutor.java:33) 的类路径中找不到 OpenStack4j 连接器51) 在 org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:78) 在 org.openstack4j.openstack.client.OSClientBuilder$ClientV3.authenticate(OSClientBuilder.java:127) 在 com.example.michaelwizard 的 org.openstack4j.openstack.client.OSClientBuilder$ClientV3.authenticate(OSClientBuilder.java:163) .coudapp.ObjectActivity.ObjectOpenStack4j(ObjectActivity.java:87) 在 com.example.michaelwizard.coudapp.ObjectActivity.onClick(ObjectActivity.java:104) 在 android.view.View。performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler .java:95) 在 android.os.Looper.loop(Looper.java:148) 在 android.app.ActivityThread.main(ActivityThread.java:5417) 在 java.lang.reflect.Method。在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 的 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 调用(本机方法)
这是我的代码
void ObjectOpenStack4j() throws JSONException, ParseException {
JSONParser parser = new JSONParser();
Object obj;
JSONArray vcapArray;
JSONObject jsonObject
,vcap
,credentials;
String envServices,username = null,password = null,auth_url = null,
domain = null,project = null;
Identifier domainIdent,projectIdent;
String envApp = System.getenv("VCAP_APPLICATION");
System.out.println("VCAP_APPLICATION - " + envApp);
envServices = System.getenv("VCAP_SERVICES");
System.out.println("VCAP_SERVICES - " + envServices);
if (envServices != null && envServices.length() > 0) {
//
obj = parser.parse(envServices);
System.out.println("Result: "+obj.toString());
jsonObject = (JSONObject) obj;
vcapArray = (JSONArray) jsonObject.get("Object-Storage");
vcap = (JSONObject) vcapArray.get(0);
credentials = (JSONObject) vcap.get("credentials");
username = credentials.get("username").toString();
password = credentials.get("password").toString();
auth_url = credentials.get("auth_url").toString() + "/v3";
domain = credentials.get("domainName").toString();
project = credentials.get("project").toString();
}else{
username = "xxxxxxxxxxxxxxxxxx";
password = "xxxxxxxxxxxx";
auth_url = "https://xxxxxx.open.xxxxxx.com";
domain = "12345";
project = "xxxxxxxxxxxxxxxxxx";
}
domainIdent = Identifier.byName(domain);
projectIdent = Identifier.byName(project);
OSClient os = OSFactory.builderV3().endpoint(auth_url).
credentials(username, password, domainIdent).scopeToProject(projectIdent,
domainIdent)
.authenticate();
SwiftAccount account = os.objectStorage().account().get();
System.out.println("Result: "+account);
}
这是我的毕业设置
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.xxx.coudapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(
'proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.google.code.findbugs:jsr305:3.0.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.cloudant:cloudant-sync-datastore-android:0.15.5'
compile 'com.cloudant:cloudant-sync-datastore-javase:0.15.5'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile 'org.pacesys:openstack4j-core:2.11'
compile 'org.pacesys:openstack4j-core-test:2.11'
}