我正在尝试使用Consumer_key和其他凭据发出GET请求,但是由于某种原因,它会引发一些错误。
代码:
String RESOURCE_URL = Keys.WC_URL;
String SCOPE = "*"; //all permissions
Response response;
OAuthRequest request;
String responsebody = "";
OAuthService service = new ServiceBuilder()
.provider(OneLeggedApi10.class)
.apiKey(Keys.CONSUMER_KEY)
.apiSecret(Keys.CONSUMER_SECRET)
.signatureType(SignatureType.QueryString)
.debug()
/*.scope(SCOPE).*/
.build();
request = new OAuthRequest(Verb.GET, RESOURCE_URL);
service.signRequest(new Token("", ""), request);
错误
2018-11-12 10:37:42.914 11337-11337/xxxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: xxxxx, PID: 11337
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/DatatypeConverter;
at org.scribe.services.DatatypeConverterEncoder.encode(DatatypeConverterEncoder.java:10)
at org.scribe.services.HMACSha1SignatureService.bytesToBase64String(HMACSha1SignatureService.java:51)
at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:46)
at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:145)
at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
at org.scribe.oauth.OAuth10aServiceImpl.signRequest(OAuth10aServiceImpl.java:120)
at xxx.activity.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3061)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:114)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.bind.DatatypeConverter" on path: DexPathList[[zip file "/data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/base.apk", zip file "/data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_dependencies_apk.apk", zip file "/data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_resources_apk.apk", zip file "/data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_0_apk.apk", zip file "/data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.xxx-KcEHeGcuPS3kKXGpOkK_KQ==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.scribe.services.DatatypeConverterEncoder.encode(DatatypeConverterEncoder.java:10)
at org.scribe.services.HMACSha1SignatureService.bytesToBase64String(HMACSha1SignatureService.java:51)
at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:46)
at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:145)
at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
at org.scribe.oauth.OAuth10aServiceImpl.signRequest(OAuth10aServiceImpl.java:120)
at xxx.activity.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3061)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:114)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/xxx-KcEHeGcuPS3kKXGpOkK_KQ==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
2018-11-12 10:37:42.916 11337-11337/xxx E/AndroidRuntime: at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5783)
at android.app.ActivityThread.access$1100(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1663)
... 6 more