【问题标题】:Android - Upload Image in a Azure ContainerAndroid - 在 Azure 容器中上传图像
【发布时间】:2014-10-09 21:31:59
【问题描述】:

我已使用以下代码从 android 将图像上传到 azure 的存储容器中。它在“// 创建 blob 客户端”行上引发错误。一些 java.lang.verifyError。我已搜索解决此错误,但找不到任何解决方案。

String connectionString = "DefaultEndpointsProtocol=https;AccountName=StorageAccountName;AccountKey=StorageAccountKey"

CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);

// Create the blob client
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

// Get a reference to a container
// The container name must be lower case
CloudBlobContainer container = blobClient.getContainerReference("images");

// Create the container if it does not exist
container.createIfNotExists();

// Create a permissions object
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

// Include public access in the permissions object
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);

// Set the permissions on the container
container.uploadPermissions(containerPermissions);

// Create or overwrite the "myimage.jpg" blob with contents from a local file
CloudBlockBlob blob = container.getBlockBlobReference("myimageYdolo.jpg");
File source = new File(currImageURI.toString());
blob.upload(new FileInputStream(source), source.length());

这是我得到的错误:

08-16 14:48:15.045: W/dalvikvm(5579): VFY: unable to find exception handler at addr 0x2b
08-16 14:48:15.045: W/dalvikvm(5579): VFY:  rejected Lcom/microsoft/azure/storage/ServiceClient;.uploadServicePropertiesImpl (Lcom/microsoft/azure/storage/ServiceProperties;Lcom/microsoft/azure/storage/RequestOptions;Lcom/microsoft/azure/storage/OperationContext;Z)Lcom/microsoft/azure/storage/core/StorageRequest;
08-16 14:48:15.045: W/dalvikvm(5579): VFY:  rejecting opcode 0x0d at 0x002b
08-16 14:48:15.045: W/dalvikvm(5579): VFY:  rejected Lcom/microsoft/azure/storage/ServiceClient;.uploadServicePropertiesImpl (Lcom/microsoft/azure/storage/ServiceProperties;Lcom/microsoft/azure/storage/RequestOptions;Lcom/microsoft/azure/storage/OperationContext;Z)Lcom/microsoft/azure/storage/core/StorageRequest;
08-16 14:48:15.045: W/dalvikvm(5579): Verifier rejected class Lcom/microsoft/azure/storage/ServiceClient;
08-16 14:48:15.045: D/AndroidRuntime(5579): Shutting down VM
08-16 14:48:15.045: W/dalvikvm(5579): threadid=1: thread exiting with uncaught exception (group=0x41dc6ba8)
08-16 14:48:15.045: E/AndroidRuntime(5579): FATAL EXCEPTION: main
08-16 14:48:15.045: E/AndroidRuntime(5579): Process: com.example.azuretry, PID: 5579
08-16 14:48:15.045: E/AndroidRuntime(5579): java.lang.VerifyError: com/microsoft/azure/storage/ServiceClient
08-16 14:48:15.045: E/AndroidRuntime(5579):     at com.microsoft.azure.storage.CloudStorageAccount.createCloudBlobClient(CloudStorageAccount.java:715)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at com.example.azuretry.FullscreenActivity.onActivityResult(FullscreenActivity.java:144)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.Activity.dispatchActivityResult(Activity.java:5423)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3347)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3394)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.ActivityThread.access$1300(ActivityThread.java:135)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.os.Looper.loop(Looper.java:136)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at android.app.ActivityThread.main(ActivityThread.java:5001)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at java.lang.reflect.Method.invokeNative(Native Method)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at java.lang.reflect.Method.invoke(Method.java:515)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-16 14:48:15.045: E/AndroidRuntime(5579):     at dalvik.system.NativeStart.main(Native Method)

【问题讨论】:

  • 你能发布整个异常堆栈跟踪吗?

标签: android azure blob


【解决方案1】:

我遇到了同样的问题,很可能是您正在使用的依赖项。使用下面的库解决了 Android 应用程序开发的问题。

一旦我使用了它,一切都正常了。 https://github.com/Azure/azure-storage-android

dependencies {
    compile 'com.microsoft.azure.android:azure-storage-android:0.3.0@aar'
}

【讨论】:

猜你喜欢
  • 2019-01-21
  • 1970-01-01
  • 1970-01-01
  • 2014-04-19
  • 2014-06-21
  • 1970-01-01
  • 2020-09-03
  • 2020-12-22
  • 1970-01-01
相关资源
最近更新 更多