无法获得访问变量 - android.content.res.Resources $ NotFoundException:字符串资源ID
问题描述:
当我试图进入一些变数,但我做这些得到错误:
new ProductAction(ProductAction.ACTION_PURCHASE)
or
Resources.getSystem().getString(R.string.TransactionAffiliation)
Eror:
android.content.res.Resources$NotFoundException: String resource ID
之前,要更改计算机(移动项目),并创建文件夹通过将文件放入它们来组织项目,本工程工作perfectely,但这些变化后,我得到这个错误。这是通过移动文件夹中的文件,我得到这个错误?
完整的错误:
08-16 08:59:28.928 5087-5252/fr.solutis.solutis E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: fr.solutis.solutis, PID: 5087
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f08003a
at android.content.res.Resources.getText(Resources.java:244)
at android.content.res.Resources.getString(Resources.java:330)
at fr.solutis.solutis.helpers.GoogleAnalytics.envoieTracker(GoogleAnalytics.java:38)
at fr.solutis.solutis.DemandeGratuite$AsyncSoapCall.doInBackground(DemandeGratuite.java:1935)
at fr.solutis.solutis.DemandeGratuite$AsyncSoapCall.doInBackground(DemandeGratuite.java:1924)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
的AsyncTask:
private class AsyncSoapCall extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
SOAP soap = new SOAP();
//soap.envoieDemande("SendLead", xml);
Reponse ret = soap.envoieDemande("SendLead", xml);
System.out.println(ret.getCode() + ret.getMessage() + ret.getOption());
if (ret.getCode().equals("1")) {
GoogleAnalytics ga= new GoogleAnalytics(getActivity());
ga.envoieTracker(idApplication, demandeId, logement, typeForm);
}
return null;
}
助手/ GoogleAnalytics.java:
private Context context;
public GoogleAnalytics(Context context) {
this.context = context;
}
public void envoieTracker(String idApplication, int demandeId, String logement, String typeForm){
DatabaseHandler db = new DatabaseHandler(context);
String id = idApplication + demandeId;
//if (code.equals("1")) {
db.updateStatutDateEnvoie(demandeId);
Product product = new Product()
.setId(id)
.setName(logement)
.setCategory(typeForm)
.setBrand("")
.setVariant("")
.setPrice(1)
.setCouponCode("")
.setQuantity(1);
ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
.setTransactionId(id)
.setTransactionAffiliation(Resources.getSystem().getString(R.string.TransactionAffiliation))
.setTransactionRevenue(1)
.setTransactionTax(0)
.setTransactionShipping(0)
.setTransactionCouponCode("");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
App app = new App();
Tracker t = app.getTracker();
t.setScreenName("Demande");
t.send(builder.build());
//}
}
答
看看你String.xml是在正确的文件夹。
应该在\app\src\main\res\values\string.xml
确定它在这里。 –
R的导入是正确的? –
我想,因为当我没有得到错误,当我按下控制按钮时,它给我的字符串,我只是做了编辑withb更多的代码 –