I can't see "hello world" [duplicate] - android

This question already has answers here:
Why textView "Hello world!" isn't showing on screen?
(3 answers)
Closed 4 years ago.
I'm learning how to build an app through Android Studio. According to the tutorials, I'm supposed to see "Hello World" when I select Activity main/ Design. Instead, it's blank and when I add a button doesn't show anything in the design.
Did I miss anything? I checked different YouTube videos and forums, I couldn't find a response. How can I fix it?

As we both can see, in the upper right corner of your screen there is a red circle error indicator. Click on it and it will pop up a screen were the respective error is explained.
If there are any errors of syntax or stuff like that, it will provide short descriptions of where the error is located and how to solve it. If not, sometimes the program has some bugs and a "Refresh Layout" button will appear in the error log. Click on that and it might solve the problem.
You can also go in File > Sync With File System and File > Sync Project With Gradle Files
Hope this helps

Go to Gradle Scripts and inside Gradle Scripts changes the dependencies for these:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Or just change the implementations:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
I think that it happens for the version of android.

Related

Android Studio XML doesn't show anything in Design View. (empty screen)

I checked other questions, but they all are about blank screen(white screen or theme). But in my case, it shows literally nothing.
I tried 'Force Refresh Layout'. But It didn't work. And only reboot can solve problem. just closing and opening Android Studio doesn't solve this problem(I even tried with removing cache and restart.)
Which one of Android Studio is related to Design View? I don't want to reboot and even though I reboot, this problem keep occurring, So, I need some better way to solve this problem.
Try this solution and see if any one actually works
Update your constraint layout dependency
change the dependencies in your gradle module file to something like this Specially and sync it implementation'androidx.constraintlayout:constraintlayout:2.1.1'
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
Invalidate Cache/restart
File>Invalidate Cache/restart
Disable and Enable android support apk
File>Settings>plugins>Under Installed section -> disable and enable and see if it works
You will be able to see if you use any Theme.AppCompat theme to your constraint layout. For example
android:theme="#style/AppTheme.NoActionBar"

Problem with rendering, how can I solve it?

I have a problem with the preview of my app.
In the log file i have a few errors :
This is a group project but I am the only one encountering this problem. I just downloaded Android Studio so I did not touch anything in the settings.
Any idea?
Add constraint layout dependency in build.gradle
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Just click the blue text that prompt in your console
or try to add these into your gradle (app level)
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
And you can update them to latest version if Android Studio tells you there's a new version.

Gradle could not find method compile() - v28?

I've been getting an error when syncing Gradle:
Could not find method compile() for arguments [com.android.support:support-core-utils:28.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
I've found solutions for previous versions but I've been developing for v28, and I'm not even sure if my compile "com.android.support:support-core-utils:28.0.0" line is correct. This is for a firebase chat app and I'm following a 2016 tutorial. I did end up installing the support thing from the manager but same error.
You can not use compile in version 4.4 of Gradle and instead reduce it by using implementation method
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
I have also completed a quite similar tutorial - creating the "Flashchat" app.
I ran into the same problem - apparently they updated the keyword used in the gradle files:
build.gradle (Module: app) - you will find dependencies at the bottom.
There you will be able to add the firebase libary as well as other ones. Example:
implementation "com.android.support:support-core-utils:28.0.0"
Unfortunately, the tutorial from 2016 is outdated so you might find several of those little changes later on. For example creating the firebase database will be a little different because they introduced a Real Time Database. (You can still use the old one for your chat app but you will have to change the ruleset for read and write access.)
For further questions you might run into, I recommend searching for "Flashchat" on GitHub. Many people have followed that tutorial and have uploaded their results. This might solve upcoming questions by just comparing the code and then looking up the documentation to understand what has changed. Link to GitHub

Android Studio 3.1.3 render fail, missing styles, failed to insantiate one or more classes

I wanted to get started with learning to code for android devices and for this i've bought a course on udemy. Unfortunately after the third video I couldn't go on because of some very annoying problems in the Android studio version 3.1.3. I tried to solve the problems but since i'm just a very beginer in programming and espacially in java I didn't stand a chance to solve it on my own and sadly every solution which i've found on the internet didn't function. So here is my problem.
Every time I start a project (no matter which) the layout won't load. And then I get this 4 messages.
Pic 1
Pic 2
I think the render problem is because of the missing styles and the missing styles are because of the classes which failed to instantiate. I think the private ressources problem is independent. So I really have no clue how to solve this problem. I think i tried almost everything. Is it possible that it has something to do with the java development kid? I've downloaded the newest version but I'm not sure if Android Studio is using it. Or maybe something with the normal java software is wrong.
Maybe the build.gradle will help you to find a solution:
pic 3
I really appreciate your time and your answers and if you need some further information please let me know.
Thank you and kind regards
Gmunderos7
UPDATE:
I've downloaded both versions on this website:
https://developer.android.com/studio/preview/?utm_source=android-studio
And both of them don't have this problems (just the private ressource). Would you recommend using one of the versions (or maybe an older version than 3.1.3 which don't has this problems)?
And can someone even use version 3.1.3 without such problems?
Step 1: "File" -> "Invalidate caches / Restart" -> "Invalidate"
Step 2: "File" -> "Close project"
Step 3: In launcher window delete your project
Step 4: Open your project by "Open an existing Android Studio project"
Step 5: Write nice code :)
I had the same problem and i fixed it today, I changed my dependencies into these
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'android.arch.core:runtime:1.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.google.firebase:firebase-core:16.0.0'
apply plugin: 'com.google.gms.google-services'
}

Android Studio throws error with empty project

I get that error:
style attribute 'android:attr/metaButtonBarStyle' not found
I get it on a new empty project on a just installed version of Android Studio.
I've tried rebuilding the project, adding the property metaButtonBarStyle in the generated values.xml file, disabling AAPT2 on gradle-wrapper.properties with android.enableAapt2=false, I've tried uninstalling plugins and Android Studio, starting with a just-installed version of Android Studio with an empty project and I still get the error.
this are my dependencies:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
could anybody help me with this?
Downgrading which SDK you're using may help unless you need a particular one.
I know when I was using Android's SDK with the Unity game engine I had to go in and delete/rename a folder to trigger Unity to download versions of those files that worked, I don't know if a similar auto-repair is available in Android Studio but if there is you might want to locate where metaButtonBarStyle should be and rename the parent folder.

Categories

Resources