简体   繁体   中英

Can't get access to variables - android.content.res.Resources$NotFoundException: String resource ID

When I'm trying to access to some variables, but I get errors by doing these:

new ProductAction(ProductAction.ACTION_PURCHASE)
or
Resources.getSystem().getString(R.string.TransactionAffiliation)

Eror:

android.content.res.Resources$NotFoundException: String resource ID

Before to change computer (move the project) and create folders to structure the project by putting files in them, the roject worked perfectely, but after these changes I get this error. It's by moving the files in folders that I get this error ?

Full error:

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;
    }

helpers/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());
    //}
}

See if your String.xml is on the right folder.

Should be on \\app\\src\\main\\res\\values\\string.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM