Android Studio 'forgetting' that layout files exist - android

Noob Android Studio 3.6.1 on Mac Mojave developer here. I have a very simple app with a few activities. Every so often, the Kotlin class for one of the activities will complain of an unresolved reference to the corresponding layout XML file.
For example, in the Kotlin Class (TraceActivity.kt), I have the following code:
setContentView(R.layout.activity_trace)
and the corresponding XML file lives at:
MyApp/app/src/main/res/layout/activity_trace.xml
All pretty standard stuff I reckon. But setContentView would complain that it couldn't resolve activity_trace. This has happened on a few occasions, and I discovered that restarting would resolve the problem. But this morning, it isn't helping. And it's also started complaining about some of the strings I've added to strings.xml
I managed to get round the errors by making use of the full names for each of the items e.g.
com.mysite.myapp.R.layout.activity_trace
and
com.mysite.myapp.R.string.my_message
So my guess (as a noob) that somewhere it's losing track of where it is. And yet my other activities are perfectly happy when I omit the full location. Can anyone offer some insight here? Thank you - SO is awesome.

Related

Unable to serialize DslActivationStatus state...Android Studio

If this is a stupid question because I made some terrible mistake, please let me know. Anyways, I just encountered the error and after searching on internet for quite some time, the only similar error that I could find was here But my situation was different.
1). I tried to create a new project from File menu of a previous project.
2). I clicked on Basic Activity and selected mininimum supported API to be 19.
3). I was following this tutorial by Google Developers.
4). I was previously able to successfully build and run from Empty Templates, but now, even they show this same error.
Here are two screenshots: Error & Window
I have tried to restart computer. I have NOT yet tried to download and re-install Android Studio yet. I do not know of any good troubleshooting besides restarting computer; so, if someone wants to share some tips, please be kind enough to do it.
I have not edited or tried to do anything in the automatically created project. I have not editted any file, until I noticed that even #color/primaryColor could not be resolved. So, I went on to look into the res/values/color file and found out that it had no color values in it, instead there was a single line: androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au. So, I checked further, and found out that many of the automatically generated files had several errors in them.
I am on a Windows 10 machine. Please help, if this question needs to be edited, please let me know. Thanks a lot in advance.

Android studio all xml layout broke and now contains java code

I was coding these past two weeks and it was compiling/running fine. Bear with me on the history as it might be relevant to the final issue.
One morning I start getting modules not found error and gradle warnings, out of nowhere.
I solve it then proceed to have a "Default activity not found". After I made sure I had a launcher activity in the manifest file, I figured I had a much bigger problem :
80% of my layout XML (in the /res folder) Are now containing chunks of my java code, in a completely random manner.
The icing on the cake : when I rollback to previous commit, as old as 2 weeks ago (that where running 100% fine), they also have the "broken xml java layouts"
It's one of the weirdest things that happened to me for a long time, please share anything that might give a clue.

How to understand R, and how it works with google's project tango

I am trying to get a tango project working with android studio and have reached a point of which I can't seem to get past, ad it is in great part to my lack of understanding of things dealing with android in general. Right now I am getting errors, the system cannot seem to find R.id.pose. R.id exists, and has many static members, but pose is not among them. I am getting the code from the samples on github, which I would assume was built to work, so I can only guess that this may be an issue with android studio? I would appreciate knowing more about any of this.
This sample indicates that R.id.pose is a TextView. I don't want to seem insulting in saying this (I don't know your experience), but in order for the system to find an id (R.id.something), it needs to be defined in a layout or resource file (the XML files in the res folder).

Android Studio "Cannot resolve symbol XXX" on basic Android tutorial

I'm doing the entry level tutorial on the official Android docs. I'm currently at this step where I'm creating the second activity:
http://developer.android.com/training/basics/firstapp/starting-activity.html
The problem I'm seeing is in creating the new activity when I have to give it a hierarchical parent in the New Activities popup. I enter the name of the parent (com.juannerito.montaigne.MainActivity) but the popup doesn't recognize it and wont't let me create the new actvity.
Added to that I'm seeing a lot of "cannot resolve symbol" errors in the MainActivity class file. I'm not sure that these errors are having any material difference on the build (though I can't be really sure, as I'm a total noob), but i feel like I have to resolve these issues first before i can fix the real issue I'm having.
I'm using Android Studio 0.26 on MacOS X 10.8.4.
any help gratefully appreciated!
I just did an update to 0.26 and had the same problem. CLosing the project, and restarting Android studio and then opening the project seems to have cleared whatever it was that was causing this.
so, it turns out that Studio is (understandibly) buggy, and that these errors are false negatives...
I can also add the hierarchical parent by hand in the code so the question about the popup is moot too :/

Android dalvikvm can't find/link to class

I've been working on an app for some time now and recently it keeps crashing on startup.
The error that causes it to crash is java.lang.ClassNotFoundException on my launcher activity. I've launched and debugged my app tons of times with no problems so I think I must've accidently changed something in a configuration file somewhere but I can't work out where.
I've checked the manifest file and there's nothing wrong, the path for the activity is correct and I've looked through the class file itself and again the package prefix is correct. I've also gone through the file directory and there's nothing wrong there either.
I tried changing the launcher activity to another one inside the same application and it runs with no problem, I've also tried creating a new launcher activity and that runs with no problem.
However, when I create a new activity and paste in all the code from the one that crashes the whole app crashes again. Even when the new activity has a different class name.
Also just before the app crashes I get two warnings:
Unable to resolve superclass of Lcom/bend/... and Link of class 'Lcom/bend/... failed
Now everything in my app is com.bend... NOT Lcom.bend... but I can't find anywhere where it's written Lcom. But I don't know if that's the cause of the problem or just a change the system does.
I know it's a real obscure problem but I just cannot figure it out. Any help would be awesome.
EDIT: I've just tried running another app I've done that's has a similar design and it's doing exactly the same thing.
I've just recently updated the SDK. Could that be the problem?
I've just solved it by creating an entirely new Android project and copying the java files and resources etc. into the new project.
I think it might have been the v4 support library that was causing the problem. I'm using a lot of Fragments so was relying heavily on it. Though I tried replacing the .jar file from an app that worked and it didn't seem to help...
In any case it was nothing to do with any of the classes or the manifest file.

Categories

Resources