Just installed Android Studio and installed a Nexus 5 emulator. Now, when designing apps in AS you commonly see a phone in the design tab. I do, but when adding new fields, texts, images etc the screen (both design and blueprint) stays static i.e does not change. Note that when running the app my emulator works fine, but it seems I can't design it in real-time. There are no errors related to this, it's just static.
So as you can see in this image below, I have one text field and one image, when running it the emulator works fine. But the AS phone is just blank.
How do I solve this so I can design more easily in Android Studio?
Static phone
Error messages
try to force refresh the layout
Your image shows the error clearly as
'Render error'
'missing constraint in ConstraintLayout'
As per documentation
Although a missing constraint won't cause a compilation error, the
Layout Editor indicates missing constraints as an error in the
toolbar. To view the errors and other warnings, click Show Warnings
and Errors . To help you avoid missing constraints, the Layout Editor
can automatically add constraints for you with the Autoconnect and
infer constraints features.
Look for more details here
Add proper constraint and you will be able to see your UI components in the preview.
Related
so I'm trying out Android Studio for the first time, and I've already run into something. I'm following the official "first application" tutorial on developer.android.com, but it's not matching up. So, I tested this with two apps, and it wasn't like a bug in the first one exclusively, it happened in both. Here's a pic of an app where nothing has been changed and I followed the tutorial exactly:
As you can see in the hierarchy, it is supposed to have the Hello World text that displays when you make a new app. However, with me not changing anything, it's not showing up.
Any ideas?
Also to clarify, the items do show up when I run it on my device, it just doesn't show up on the computer.
Check the upper right corner of the Preview screen, you should see a red warning mark. Click on that and it will tell what is preventing Android Studio from rendering your layout.
Some times android studio stuck or something.Try doing
File->Invalidate Caches/Restart
The best solution is
Clean Project
Rebuild Project
In your style.xml file change the string parent with the below line:
parent="Base.Theme.AppCompat.Light.DarkActionBar"
I am working on an instant app demo app. I used the default template which I extended with a RecyclerView and a custom adapter. My problem is that my layout is totally broken:
As you see the toolbar is the same, but something does not work correctly regarding the coordinator layout. The floating action button is missing and the navigation drawer is not displayed below the system UI (the notification area) and yep of cause the menu is empty.
The both screens are debug builds so proguard is not messing anything up (I got also release working with proguard, but of cause I still have the same issue). On the left is the result of the gradle task :app:assembleDebug and on the right :instantapp:assembleDebug.
Since I use except of the recycler view the default template for this app I add no code, any idea why my layout is broken in instant apps?
Please follow these steps and you should be good to go!
https://developer.android.com/topic/instant-apps/getting-started/first-instant-app.html
Note : Please select Navigation Drawer Activity in Step 8
From the shared image, it looks like you have modified some code from the default Navigation Drawer Activity for your IA. If yes, please share the code to investigate.
Also, let me know the device/emulator and the Android studio you are using. I was not able to reproduce the issue with Studio version 3.0.1 on Nexus 5x (Android version 8.0.1). Following is the image of the instant app from my nexus 5x with 8.0.1 build. Let me know if I am missing something!
I have faced a problem when creating project in Android Studio 2.2
When trying to create xml layout, I get following warning:
When click to Show, I get the following error
How can I fix this?
It's just a warning, indicating that some details might not be rendered, not an error. It's a problem of the layout preview in Android Studio. It doesn't affect the final app at all. You can continue your work fearlessly It is just showing some of the components may not be accurate as you have set them in the xml file, but in reality, that view may possess some animation. Just press "Ignore all fidelity warnings for this session" so that you won't be disturbed with this warning again during your current work session.
This is the error I'm getting in my layout XML files:
error!
NotFoundException: null
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- TextView (Change to android.widget.TextView, Fix Build Path, Edit XML)
This happened after updating my SDK tools in Eclipse. However, I can still compile my code, I just can't see the graphical part of my layout.
Recently, I also added the RootTools library, could that also be the cause?
Thank you!
I had the same problem. And it turned out to be a very strange thing.
In my strings.xml file I had a line
<string name="email_seperator_char">\#</string>
And this was causing the problem. Even if I use the escape character for # sign preview was not working after SDK update.
SOLUTION:
I just added a space in front of it and voila, it worked.
<string name="email_seperator_char"> \#</string>
I know it is strange and it may not be acceptable for some apps to have an space infront of it. But that was ok for my app. Hope this helps.
And in design mode, in graphical layout, you have a new icon, (android icon), click and select 8 minimum.
I'm not sure it helps in your case, but I found out what was the problem with mine. To support older Android devices, I lowered my project build target to API level 7 (Android 2.1) from the previous value of API Level 8 (Android 2.2).
There might be an issue with the 2.1 layout renderer, it kept crashing on my TextView's property android:textAppearance="?android:attr/textAppearanceMedium". Even when I removed it, rendering was working but had a strange appearance (grey background, tiny black text). Switching the API level back fixed the layout editor straight away.
To change it, go to your project properties, select Android on the right, then tick the box next to your desired API level under Project Build Target.
I ve got the same issue just a minutes ago, try to lower the API level, press the andorid green icon in the layout editor screen and on the dropdown menu select API 7. I think it would be work out.
I've been having similar issues. After reading a number of these posts, I've found that there is probably a bug in the layout renderer for Android 4.0.3. An error message is listed (ROOT
Exception details are logged in Window > Show View > Error Log) even when all parts of the project are set to Android 4.0.3 and SDK 15.
If I set the layout renderer to Android 2.2 and leave everything else set to Android 4.0.3, SDK 15, then it all appears to work just fine.
I hope this is useful.
there is something wrong in your TextView
one time I wrote this which cause the problem
android:textAppearance="#android:attr/textAppearanceLarge"
the Eclipse can`t tell that is wrong but the design view crashes,when I realized that,I change # to ?
android:textAppearance="?android:attr/textAppearanceLarge"
then all comes to normal
I looked up on getting an emulator for a tablet and noticed a suggested that on checking for updates within eclipse , the latest SDK/ADT etc would provide this. At the moment I cannot check this because I am getting the following error on my main.xml file.
error!
NotFoundException: null
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- ToggleButton (Change to android.widget.ToggleButton, Fix Build Path, Edit XML)
I have tried the three options it offers and on choosing edit XML nothing appears to show an error.
This project runs under Android 1.6 (wanted to make it as backward compatible as possible) and trying to cope with different screen sizes and orientations . At the moment I have the following layout folders:
layout(empty folder)
layout-large
layout-normal
layout-normal-land
layout-small
layout-xlarge
These all existing before the eclipse/android updates and I never had these errors. I searching the net on these , I read one suggestion of Project->clean (done this) and I then did Project->Build.
I also a suggestion to remove r.java so I have done this and ran clean and build. Still getting the same error. Oddly the code and the xml show no signs of errors apart from the above message appears at the bottom of the designer window for the XML.
The designer is set to 1.6 (API4) so it is not that the designer thinks I am on a different version to my project.
Update 1:
Since moving onto 2.1 - I found that although the layout does not show the error straight away, it then appears if I try and make any changes to it. Also I have updated the images and these do not appear to have changed either.
Update 2:
feco has suggested a reasonable suggestion of moving the build target to 2.1 as only a small percentage of users operate with a 1.6 handset now. I have decided to do this , it is more of a get around than a solution but it will have to do right now.
I had the same problem. I solved it by changing from API4 to API10 (or more) in the "Graphical Layout" window -> upper menu -> Android logo (green robot) at the end