0

I had to change my package name from com.example.chris.myapplication to com.tamaritz.chris.myapplication so that my app could be properly loaded and distributed via Google Play Store. To do this, I used the approach Android Studio Rename Package which was to basically create a new directory, copy contents, update Manifest. I got those steps down but I am having trouble with "change/rename the R file imports in whole project". When I made my package name change, my line of code(below) said "R cannot be resolved".

        submit = (Button) v.findViewById(com.example.chris.myapplication.R.id.submitButton);

When I went to the imports part of the java source code(below)

package com.tamaritz.chris.myapplication;
import android.app.Activity;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

Everything seemed to be line place, the right package name.

Do I have to put a manual R import? The person said to change/rename the import but I don't even see the original R import.

And this something else I did which I am not sure. A possible solution I found was just to do alt enter, and import the class. That line of code suddenly turned into

            submit = (Button) v.findViewById(R.id.submitButton);

Is this a valid approach. Does the package name explictly need to be there? After I did this, i did not see any changes in the import section either.

Community
  • 1
  • 1
committedandroider
  • 8,711
  • 14
  • 71
  • 126
  • Try to right click on your project and select Replace path option from popup list then replace your old package with new in all files. – Haresh Chhelana Dec 15 '14 at 04:32
  • Thank you. In my example what is the difference between R.id.submitButton and com.tamaritz.chris.myapplication.R.id.submitButton? They both compile fine. – committedandroider Dec 15 '14 at 05:26
  • 1
    com.tamaritz.chris.myapplication.R.id.submitButton it is call inline import statement so if you not import at class level then you have to import each line like inline import. – Haresh Chhelana Dec 15 '14 at 05:32
  • yeah i guess its better to have import com.tamaritz.chris.myapplication.R at the top – committedandroider Dec 15 '14 at 08:27

0 Answers0