Android Realm initial setup - android

I would like to start using Realm for android but i having problem setting it up. i follow the instructions located at https://realm.io/docs/java/latest/#getting-started but still doesnt work.
here is my gradle(project)
here is my gradle (app)
i create a class and extend RealmObject, android studio complains and give me message "Cannot revolve symbol Realmobject". here is a snaphot of my class
my gradle are syncing up fine and there is no error while syncing but for some reason i am not able to start coding Realm object. can someone help me and tell me what i am doing wrong? im using android studio 3.1.3

the problem is that apply plugin: 'realm-android'
also needs to be added to gradle(feature) file

Related

Android Studio xml preview issue failed to initialize editor

After Update android studio dolphin my old projects xml preview not showing views. Is anyone facing same issue? And have done solution then please share it here.
It's run perfectly fine but preview not working.
What I did tried?
File -> Invalidate Cashes / Restart
Delete build , idea , gradle folder
Restart PC and android studio
but none of that solved my problem.
In my case, I have upgraded the project AGP (Android Gradle Plugin) and then restart the android studio.
Problem Solved.
I'm suffering from same issue/bug. What I did so far?
Attempt 1
File -> Sync Project with gradle files
File -> Invalid catch and Restart.
Delete build folder idea and .gradle folder.
Restart Android studio and restarted my pc as well.
This will do solve in one of the my project which is only 5 screen project. But not solved in my other old projects which are more than 5 year old.
Attempt 2
Tried all step from attempt 1 Also tried what siregar2103 answered
File -> Repair IDE but still have same problem ,But Repair IDE did solve my other project issue/bug.
Attempt 3
All from Attempt 1 and 2 but not solve in my main project so I decided to upgrade my years old project to latest one.
I did upgrade my Gradle from 4.1.3 to 7.3.0
Update all dependency to latest one but I face many error while doing that.
Hilt error and other errors too. Which I'm going to mention below.
For Hilt I did removed all old Hilt related library and and below
kapt "com.google.dagger:dagger-compiler:2.42"
kapt "com.google.dagger:hilt-android-compiler:2.43.2"
implementation "com.google.dagger:dagger:2.42"
implementation "com.google.dagger:hilt-android:2.43.2"
implementation 'androidx.hilt:hilt-work:1.0.0'
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation "androidx.navigation:navigation-compose:2.5.1"
In build.gradle file (not .app level)
id 'com.google.dagger.hilt.android' version '2.43.2' apply false
Important note: I did add implementation "androidx.navigation:navigation-compose:2.5.1" dependency because I got
java.lang.IllegalArgumentException: CreationExtras must have a value
by SAVED_STATE_REGISTRY_OWNER_KEY error in runtime.
Other Error which I faced is
Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException:
lateinit property _buildFeatureValues has not been initialized
For this I did build gradle using command line and it give me full error which I didn't get when I directly build don't know why? But It's through error related flat dir and aar file so I did removed flat dir code and change aar file implementation code now It's started to build and my app started to install.
Now still some of my file not rendering and that because of I'm using custom attr from style so I'm trying to figuring out why it's happening and I'll update this answer when I find solution for that.
So using above my 60% xml files preview start showing in my old projects. For 40% screen I have to change my default theme to custom theme in preview of xml so it can start rendering.
Repair IDE
Upgrade your code to latest Android Gradle Plugin
This 2 step should solve your problem. And build using command line for more error related details.
Have you try to using Repair IDE? It works for me
I ran into a similar issue when upgrading to Dolphin. I was able to solve this by changing the preview's theme from App.Starting [default] to my app's theme.
Try to update the gradle and sync files. It work for me.
The XML file in your project may contain an error. The reason may be a font issue or a file not linking correctly with your XML layout.
This is for your reference on how to find errors.
Hope you find it useful.
Check what Layout Inspectors you have enabled in Android Studio and try to let only the API 29-30 inspector active.
In my case if in xml custom views have used that my preview screen not show views if I remove or comment custom views in xml layout after that the preview screen show other view perfectly
I know removing custom layouts not solution.
for solve this issue I do following steps
First I just update Gradle plugin version to 7.3.0 from setting project structure (No working)
after that I also update com.google.gms:google-services version to 4.3.14
now every things work fine.
In my case, I have upgraded Android Gradle Plugin when update is popUp and then restart the android studio.
My Problem Solved.
I am looking as well for a soluition till now.
From what i see, it has something to do with
AGP or Cardview (Layouts). Many code snipeets relate to this issue.
I am trying to update the AGP version, but it seems, that the enveronmet is more broken than that.
I get as well an empty Field for the gradle version and plugin under settings.
For anyone can not fix this issue, i'm just need to update gradle version and buildtool
buildSrc/src/main/kotlin/Dependencies.kt
object BuildPlugins {
object Versions {
const val buildToolVersion = "7.3.0" //lower version seem not work
and change to 7.4 in gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

android.synthetic library isn't being recognized in android studio

In my Activity.kt class, the synthetic isn't being recognized in the import
import kotlinx.android.synthetic...
I have included the following in my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
When trying it import, it will recognize extensions and parcel
import kotlinx.android.extensions...
import kotlinx.android.parcel...
So why is synthetic the only one not being recognized?
Other info:
I have tried invalidating caches and restarting.
I have another computer that also has this android studio project (Same gradle versions and everything). Everything works fine there.
Edit:
I understand the current way to do it is to use data binding. But this is just a project we need to sustain, not improve and upgrade. We have a custom sdk (added many years ago) in the project that is making it hard to upgrade gradle and modernize.
The project, even though synthetic is not recognized, is building and uploading fine. I just want to remove these red lines of error.
Any advice on how to start trouble shooting would be greatly appreciated.
Synthetics were deprecated and removed in the latest version of Android Studio (Chipmunk). The recommendation is to migrate to using view binding. If you cannot do that, then you'll need to use an older version of Android Studio.
Migrating to view binding from synthetics is generally straightforward, so that's the better long term solution of course, but changing the IDE version is a quick short term solution.
Even projects in maintenance mode require occasional maintenance - like dealing with deprecations.

Cannot resolve symbol 'FirestoreRecyclerAdapter' in android studio

I am developing an android app that fetches the documents from a collection and for this, I am trying to use the firestore recycler adapter but I am getting error "Cannot resolve symbol 'FirestoreRecyclerAdapter'"
Same error for FirestoreRecyclerOptions
I have also added the dependency in app level build.gradle file as
implementation 'com.firebaseui:firebase-ui-firestore:6.4.0'
Also tried invalidating and clearing the cache of android studio and doing multiple grade syncs still, the errors persist
Here what I think the error could be is that the library is not properly installed but then why only this library other all firebase libraries are getting installed perfectly fine
Also important point the same library is working for different android project
Any help would be appreciated
Acc. to docs it is not FirestoreRecyclerAdapter it is FirestoreRecyclerOptions
try with latest dependency
implementation 'com.firebaseui:firebase-ui-firestore:8.0.0'

Android Studio and Kotlin: Unresolved reference: also

also compiles and runs from Android Studio:
val greeted = "World".also { println("Hello $it") }
Yet the editor highlights also and it as errors and don't give any help with intellisense. apply still works and when I go to source I can see the definition of both apply and also. How do I get Android Studio to recognize also?
Android Studio 2.3.3
kotlin_version = '1.1.3-2'
Kotlin plugin 1.1.3-release-Studio2.3-2
I've also had this problem with earlier versions.
I tried everything possible and nothing worked. The only solution for me was to delete .AndroidStudio folder from C:/Users/YourName/. Android Studio resets and everything works as it should.
The also function was added in Kotlin 1.1 but you have your Language version set to 1.0. Go to your settings/preferences and change the Kotlin version to 1.1.
In my case when i added id 'kotlin-android-extensions' to gradle file (app) and synced, problem is solved.

Problems setting up SQLDelight

I'm trying to use SQLDelight in my project. Everything seems to be working alright in respect of code generation. Unfortunately I can't use the interfaces generated under /build/generated/source/sqldelight/... in my project. When I try to create a class implementing a generated model it gets underlined with the error cannot resolve symbol 'InterfaceName'.
I prepared an example project showcasing my problem here. Any help getting it to work is of course much appreciated.
You need to apply the sqldelight plugin on the app, not the project. In your application build.gradle file, right below apply plugin 'com.android.application:' put apply plugin: 'com.squareup.sqldelight'

Categories

Resources