android - Android:android.content.res.Resources$NotFoundException:资源 ID #0x0 in
问题描述
我是 android 新手,我第一次尝试 paymnet getway intigration with android app。当我尝试从 MobilePaymentSDKOutput.jar 库中调用 PayActivity.java 时,我从 atom 的官方网站获得了适用于 android 的“sdk”并正确集成它由androidsdk
atom payment getway 给出。当我在模拟器中运行应用程序时,它显示以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.lightwave.plwpay/com.atom.mobilepaymentsdk.PayActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
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:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2155)
at android.content.res.Resources.getLayout(Resources.java:1155)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:420)
at android.app.Dialog.setContentView(Dialog.java:557)
at a.a(SourceFile:66)
at j.onPreExecute(SourceFile:796)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:648)
at android.os.AsyncTask.execute(AsyncTask.java:595)
at com.atom.mobilepaymentsdk.PayActivity.onCreate(SourceFile:2215)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
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:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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)
这是java代码:
public class MainActivity extends AppCompatActivity {
TextView whichCard;
ImageButton payNow,cancel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this, ""+ Constants.whichCard, Toast.LENGTH_SHORT).show();
try {
if (!Constants.whichCard.equals("")) {
whichCard.setText(Constants.whichCard);
}
else {
Toast.makeText(this, "Nullll", Toast.LENGTH_SHORT).show();
}
}catch (Exception e){}
payNow= findViewById(R.id.payNow);
cancel= findViewById(R.id.cancelPay);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
payNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent newPayIntent = new Intent(MainActivity.this, PayActivity.class);
newPayIntent.putExtra("merchantId", "459");
newPayIntent.putExtra("txnscamt", "0"); //Fixed. Must be �0�
newPayIntent.putExtra("loginid", "459");
newPayIntent.putExtra("password", "Test@123");
newPayIntent.putExtra("prodid", "NSE");
newPayIntent.putExtra("txncurr", "INR"); //Fixed. Must be �INR�
newPayIntent.putExtra("clientcode", "001");
newPayIntent.putExtra("custacc", "100000036900");
newPayIntent.putExtra("amt", "50.000");//Should be 3 decimal number i.e 1.000
newPayIntent.putExtra("txnid", "01");
newPayIntent.putExtra("date", "25/08/2015 18:31:00");//Should be in same format
newPayIntent.putExtra("bankid", "2019"); //Should be valid bank id
//use below Production url only with Production "Library-MobilePaymentSDK", Located inside PROD folder
//newPayIntent.putExtra("ru","https://payment.atomtech.in/mobilesdk/param"); //ru FOR Production
//use below UAT url only with UAT "Library-MobilePaymentSDK", Located inside UAT folder
newPayIntent.putExtra("ru", "https://paynetzuat.atomtech.in/mobilesdk/param"); // FOR UAT (Testing)
//Optinal Parameters
newPayIntent.putExtra("customerName", "Sweta sap"); //Only for Name
newPayIntent.putExtra("customerEmailID", "sap.sweta@atomtech.in");//Only for Email ID
newPayIntent.putExtra("customerMobileNo", "9876043210");//Only for Mobile Number
newPayIntent.putExtra("billingAddress", "Mumbai");//Only for Address
newPayIntent.putExtra("optionalUdf9", "OPTIONAL DATA 1");// Can pass any data
startActivityForResult(newPayIntent, 1);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1)
{
if (data != null)
{
String message = data.getStringExtra("status");
String[] resKey = data.getStringArrayExtra("responseKeyArray");
String[] resValue = data.getStringArrayExtra("responseValueArray");
if(resKey!=null && resValue!=null)
{
for(int i=0; i<resKey.length; i++)
System.out.println(" "+i+" resKey : "+resKey[i]+" resValue : "+resValue[i]);
}
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
}
}
}
请指导我如何解决这个问题。
解决方案
如果您确定PayActivity
存在并且没有问题,我建议您尝试清除缓存(Build -> Clean Project or File -> Invalidat Caches/Restart ...
)。您甚至可以检查包装中是否正常apk
。
推荐阅读
- python-3.x - PayPal API:创建的计费计划不会出现在仪表板中
- r - 使用 ggplot2 时渲染梵文字体
- c++ - 如何在 C++ 中通过 constexpr-if 跳过不可编译的代码?
- plot - 编译 plotshape 函数 TradingView Pine 脚本时出错
- android - 为什么不能用toolbarStyle为主题中的工具栏设置layout_height和layout_width?
- java - 实例化所有成员后枚举数组时出现 NullPointerException?
- php - 依赖项中的嘲弄和方法链接
- javascript - 在应用拆分和连接功能并替换单词时将文本字段的值输出到另一个字段
- java - 如何解决导致 GUI 冻结的 Java fx 折旧线程的问题?
- git - 从 Jenkins 在 Docker 主机上运行 docker-compose 命令