Hello everyone!

I'd like to thank you in advance for your help.

I've been trying to get help with my two problems on StackOverflow, and
I've only had limited success so far.

Here's a copy/paste from
http://stackoverflow.com/questions/34386053/problems-linking-r-id-x-in-android-studio
:

I've lurked on StackOverflow for years, but now that I'm getting serious
about Android development, I've finally started an account.

I Google searched thoroughly for help with my problem, to no avail.

I was successfully developing simple apps in Android Studio 1.4 since I
first installed the IDE on my old Linux laptop last month. Then, I
installed Android Studio 1.5 on a much better machine, because the hardware
limitations on the old laptop were really getting to me.

I was careful to install Oracle JDK 7 before installing Android Studio, and
also to enable KVM in BIOS. I also made sure to install all of the Android
SDKs that weren't specific to Android Auto.

When I started to import my old projects, Gradle was having a hell of a
time compiling them. So I decided to start a new project and copy and paste
my old code via a text editor.

I learned that I now have to activate permission checking in Java in
addition to requesting permissions in my Manifest XML, in order to
accommodate Android 6.0 Marshmallow, which is fine.

I put this code into my MainActivity.java like so:

 public class MainActivity extends AppCompatActivity implements
LocationListener {
int permissionCheck = ContextCompat.checkSelfPermission(this,
        permission.ACCESS_COARSE_LOCATION);int permissionCheck2 =
ContextCompat.checkSelfPermission(this,
        permission.ACCESS_FINE_LOCATION);

Android Studio is still marking this code in my OnCreate method in red:

Location location = locationManager.getLastKnownLocation(provider);
    onLocationChanged(location);

On mouse cursor hover, I still get: "Call requires permission which may be
rejected by user."

I also have another problem.

I made sure to assign the correct ID to the views I'm using from my
activity_main.xml to my MainActivity.java. But still, when I call
findViewById and use R.id.x, it's not linking and that bit of text isn't
purple in my IDE. Here's the code I'm referring to:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        latTV = (TextView) findViewById(R.id.lat);
        lngTV = (TextView) findViewById(R.id.lng);
    addressTV = (TextView) findViewById(R.id.address);
    altitudeTV = (TextView) findViewById(R.id.alt);

None of the R.id.x nor the R.layout.activity_main in setContentView are
turning purple as they're supposed to. As I said, I made sure that the
resources and IDs exist.

OS: Kubuntu 14.10 LTS IDE: Android Studio 1.5

Thanks in advance for your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAB_zpZFpAKzp5vpxGaCWwV7HL1Zf94wQjVNdUttuE4U%2BUDebgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to