android – 无法解析Azure云存储中的连接字符串
作者:互联网
我有一个Android应用程序,我想从Azure下载blob存储.我有一个连接字符串,但当我尝试解析它,我的应用程序给我错误和我的应用程序崩溃.我怎么能解决这个问题?
解析连接字符串的Activity:
package com.berkkarabacak.mspproje;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.TextView;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.ListBlobItem;
public class Checkactivity extends ActionBarActivity {
String tcnumara;
public static final String ConnectionString =
"DefaultEndpointsProtocol=http;"
+ "AccountName=CENSORED;"
+ "AccountKey=CENSORED";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.checkheartbeat);
try
{
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(ConnectionString);
catch (Exception e)
{
// Output the stack trace.
e.printStackTrace();
}
}
}
logcat的:
04-14 14:32:02.598 27372-27372/com.berkkarabacak.mspproje E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.berkkarabacak.mspproje, PID: 27372
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLOutputFactory;
at com.microsoft.azure.storage.core.Utility.<clinit>(Utility.java:120)
at com.microsoft.azure.storage.CloudStorageAccount.parse(CloudStorageAccount.java:239)
at com.berkkarabacak.mspproje.Checkactivity.onCreate(Checkactivity.java:36)
at android.app.Activity.performCreate(Activity.java:6283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLOutputFactory" on path: DexPathList[[zip file "/data/app/com.berkkarabacak.mspproje-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.microsoft.azure.storage.core.Utility.<clinit>(Utility.java:120)
at com.microsoft.azure.storage.CloudStorageAccount.parse(CloudStorageAccount.java:239)
at com.berkkarabacak.mspproje.Checkactivity.onCreate(Checkactivity.java:36)
at android.app.Activity.performCreate(Activity.java:6283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Suppressed: java.lang.ClassNotFoundException: javax.xml.stream.XMLOutputFactory
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
04-14 14:32:04.528 27372-27372/com.berkkarabacak.mspproje I/Process﹕ Sending signal. PID: 27372 SIG: 9
解决方法:
看看你的gradle build file看起来你正在使用Java存储库而不是Android存储库.如果您查看Android存储库的GitHub登录页面,应该有通过gradle构建导入Android aar的说明.
标签:android,azure-storage-blobs,parsing 来源: https://codeday.me/bug/20190728/1559091.html