gpt4 book ai didi

java - 修复 java.lang.ClassNotFoundException : com. codename1.braintree.impl.BraintreeNativeImpl

转载 作者:行者123 更新时间:2023-11-30 10:16:47 26 4
gpt4 key购买 nike

在为 Braintree 导入 CN1Lib 并设置我自己的 Braintree 服务器后,我准备实现 Braintree API 的客户端。我查看了 Codenameone 的 GitHub for Braintree 并按照说明使用了他们的教程代码。当我在按钮的 Actionlistener 方法下插入这段代码时,我运行了我的应用程序并收到错误:java.lang.ClassNotFoundException: com.codename1.braintree.impl.BraintreeNativeImpl

查看控制台跟踪错误,发现在jsProxy.set("onSuccessNonce", new JSFunction()这一行(代码中这一行也是用**括起来的下)

// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)


package com.codename1.braintree;

import com.codename1.braintree.impl.BraintreeNative;
import com.codename1.braintree.impl.BraintreePaymentCallback;
import com.codename1.javascript.JSFunction;
import com.codename1.javascript.JSObject;
import com.codename1.javascript.JavascriptContext;
import com.codename1.system.NativeLookup;
import com.codename1.ui.BrowserComponent;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BorderLayout;

public class Purchase {
static boolean flag;

public Purchase() {
}

public static void startOrder(Purchase.Callback callback) {
BraintreePaymentCallback.cb = callback;
String token = callback.fetchToken();
BraintreeNative bn = (BraintreeNative)NativeLookup.create(BraintreeNative.class);
if (bn != null && bn.isSupported()) {
bn.showChargeUI(token);
} else {
Form buy = new Form(new BorderLayout());
Form previous = Display.getInstance().getCurrent();
buy.getToolbar().addMaterialCommandToLeftBar("", '\ue5c9', (e) -> {
previous.showBack();
});
BrowserComponent cmp = new BrowserComponent();
buy.add("Center", cmp);
cmp.addWebEventListener("onLoad", (e) -> {
JavascriptContext ctx = new JavascriptContext(cmp);
JSObject jsProxy = (JSObject)ctx.get("{}");
**jsProxy.set("onSuccessNonce", new JSFunction() {**
public void apply(JSObject self, Object[] args) {
BraintreePaymentCallback.onPurchaseSuccess((String)args[0]);
}
});
jsProxy.set("onErrorCall", new JSFunction() {
public void apply(JSObject self, Object[] args) {
BraintreePaymentCallback.onPurchaseFail((String)args[0]);
}
});
jsProxy.set("onCancelCall", new JSFunction() {
public void apply(JSObject self, Object[] args) {
previous.showBack();
}
});
});
cmp.setPage("<html><head> <style type=\"text/css\">\n html, body {\n height: 100%;\n padding: 0;\n margin: 0; \n }\n \n /* Dummy CSS to fix bug in JavaFX webview that caused gibberish display */\n .gm-style-mtc > div, .gm-style > div, .gm-style-cc > div, .gm-style {font-family:sans-serif !important;}\n </style></head><body>\n<form id=\"checkout-form\" action=\"/transaction-endpoint\" method=\"post\">\n <div id=\"error-message\"></div>\n\n <label for=\"card-number\">Card Number</label>\n <div class=\"hosted-field\" id=\"card-number\"></div>\n\n <label for=\"cvv\">CVV</label>\n <div class=\"hosted-field\" id=\"cvv\"></div>\n\n <label for=\"expiration-date\">Expiration Date</label>\n <div class=\"hosted-field\" id=\"expiration-date\"></div>\n\n <input type=\"hidden\" name=\"payment_method_nonce\">\n <input type=\"submit\" value=\"Pay\" disabled>\n</form>\n\n<!-- Load the Client component. -->\n<script src=\"https://js.braintreegateway.com/web/3.11.1/js/client.min.js\"></script>\n\n<!-- Load the Hosted Fields component. -->\n<script src=\"https://js.braintreegateway.com/web/3.11.1/js/hosted-fields.min.js\"></script>\n\n<script>\nvar authorization = \"" + token + "\";\nvar submit = document.querySelector('input[type=\"submit\"]');\n\nbraintree.client.create({\n authorization: authorization\n}, function (clientErr, clientInstance) {\n if (clientErr) {\n // Handle error in client creation\n onErrorCall(clientErr.toString()); return;\n }\n\n braintree.hostedFields.create({\n client: clientInstance,\n styles: {\n 'input': {\n 'font-size': '14pt'\n },\n 'input.invalid': {\n 'color': 'red'\n },\n 'input.valid': {\n 'color': 'green'\n }\n },\n fields: {\n number: {\n selector: '#card-number',\n placeholder: '4111 1111 1111 1111'\n },\n cvv: {\n selector: '#cvv',\n placeholder: '123'\n },\n expirationDate: {\n selector: '#expiration-date',\n placeholder: '10/2019'\n }\n }\n }, function (hostedFieldsErr, hostedFieldsInstance) {\n if (hostedFieldsErr) {\n // Handle error in Hosted Fields creation\n return;\n }\n\n submit.removeAttribute('disabled');\n });\n});\nvar form = document.querySelector('#checkout-form');\nvar submit = document.querySelector('input[type=\"submit\"]');\n\nbraintree.client.create({\n // Replace this with your own authorization.\n authorization: 'eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJiYmIxZTc0ODhhZDJhZjBlMzhhOWFmMzYzYjAxMTJkOGJmMjRlMWFlNThmMDVhMDhjZDk5ODM5NGI1ODhkMTMxfGNyZWF0ZWRfYXQ9MjAxNy0wMy0yOVQxMzo0MDoyOC41MTc2MzM1OTgrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0='\n}, function (clientErr, clientInstance) {\n if (clientErr) {\n // Handle error in client creation\n return;\n }\n\n braintree.hostedFields.create({\n client: clientInstance,\n styles: {\n 'input': {\n 'font-size': '14pt'\n },\n 'input.invalid': {\n 'color': 'red'\n },\n 'input.valid': {\n 'color': 'green'\n }\n },\n fields: {\n number: {\n selector: '#card-number',\n placeholder: '4111 1111 1111 1111'\n },\n cvv: {\n selector: '#cvv',\n placeholder: '123'\n },\n expirationDate: {\n selector: '#expiration-date',\n placeholder: '10/2019'\n }\n }\n }, function (hostedFieldsErr, hostedFieldsInstance) {\n if (hostedFieldsErr) {\n // Handle error in Hosted Fields creation\n return;\n }\n\n submit.removeAttribute('disabled');\n\n form.addEventListener('submit', function (event) {\n event.preventDefault();\n\n hostedFieldsInstance.tokenize(function (tokenizeErr, payload) {\n if (tokenizeErr) {\n // Handle error in Hosted Fields tokenization\n return;\n }\n\n onSuccessNonce(payload.nonce);\n });\n }, false);\n });\n});\n</script></body></html>", (String)null);
buy.show();
}

if (flag) {
BraintreePaymentCallback.onPurchaseCancel();
BraintreePaymentCallback.onPurchaseFail((String)null);
BraintreePaymentCallback.onPurchaseSuccess((String)null);
}

}

public interface Callback {
String fetchToken();

void onPurchaseSuccess(String var1);

void onPurchaseFail(String var1);

void onPurchaseCancel();
}
}

我一直在尝试寻找解决方案,但想不出任何解决方案。有谁知道如何解决此错误?

最佳答案

您应该删除所有这些并使用代号一设置中的扩展管理器安装 cn1lib。

  • 右键单击该项目
  • 选择代号一 -> 代号一设置
  • 扩展
  • 输入 Braintree,点击“下载”
  • 右键单击该项目
  • 选择Codename One -> Refresh cn1libs

API 应该“正常工作”。

如果您想从代码开始工作,您还需要复制项目中的所有 native 代码并查看属性文件以将其合并到您的项目设置中。

或者,您也可以只下载项目并使用 ant 或 NetBeans 构建 cn1lib。

关于java - 修复 java.lang.ClassNotFoundException : com. codename1.braintree.impl.BraintreeNativeImpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49865938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com