Android Studio Kotlin Multiplatform project has messed up auto-complete - android-studio

I am building a Kotlin Multiplatform project in Android Studio, and the auto-complete for the common libraries that I am using is not working, but it builds in Gradle just fine.
I've tried:
invalidating the IDE's caches and restarting
cleaning my build
closing and reopening the project
all with no success.

This seems to be a bug in Android Studio at the moment. You can force the IDE to rebuild the relevant information by:
removing a module from your settings.gradle file
syncing
adding the module back in
syncing again
I don't know why this works, but it did for me.

Related

Android Studio design view not loading

I've been using android studio for a while now and I have never had any problems. Today i tried to open a new project and the Mainactivity file opens but when i try to open the design view (as shown in the picture) it just keeps loading and never stops. I tried closing and reopening android studio but it still loads without finishing. Any suggestions on how to solve this problem?
android studio
Try the below methods and let me know:
First, let the studio build the project completely. Preview won't be available until the project is built. Make sure you've correct library implementation in Gradle and you have a stable internet connection. If those are okay then follow the below methods-
Invalidate Cache and Restart Android Studio
Restart Your Computer
Create a new project and try building it.
Let me know if it fixes your problem.

Android Studio is syncing multiple projects at once

I have a Kotlin Multiplatform Project which contains an android library target. That library is imported to a separate android app project:
// settings.gradle.kts
include ":sharedLib"
project(":sharedLib").projectDir = file("../path/to/sharedLib")
Whenever I sync my app project in Android studio both the app and sharedLib projects sync in parallel. I am pretty sure this is some IDE setting i fluffed up when debugging source resolution with the sharedLib a while back.
Any ideas what AS settings i might have messed up? I actually removed AS and reset the configuration and yet I am dealing with seeing dual syncing.
Turns out it was some config stored in my project's .idea directory. Cleared it and everything is happy again.

How to configure an iOS Application for Kotlin Multiplatform in Android Studio?

I want to add a Run/Debug Configuration for an iOS Application for a Kotlin Multiplatform Mobile application in Android Studio 4.1.2. However, there seems to be a problem with the configuration for iOS.
In the screenshot below you can see the problem. In the dialog "Run/Debug Configuration" Android Studio complains about
Error: Please specify Xcode project location in xcodeproj property of gradle.properties
Using the "Fix" button does not solve the problem. Android Studio just adds an additional xcodeproj to gradle.properties and the complains about a duplicate parameter.
I also tried different paths (relative and absolute) for xcodeproj. No luck.
If I remember correctly, it used to work out of the box. A new Kotlin Multiplatform Mobile project was automatically configured for Android and iOS. I'm not sure what changed. Probably something was updated.
Is this a bug with the KMM plugin? Or is there something I can do on my system to fix this?
don't do that with Android Studio.
Just open Xcode, click on 'open another project...', locate to the iosApp folder that named it when creating your project on Android Studio.
after that, just click run and have fun.
If the project doesn't run right away even on opening it from Xcode and shows the shared framework is missing, Then try generating the shared framework for iOS platform using terminal. Navigate to the project folder and execute
Command: ./gradlew packForXcode
Now the shared framework should have a xcode-frameworks product and you should be able to build and run the project through Xcode.
I fixed it by downgrading the Kotlin version from 1.4.30 to 1.4.21. You can check this thread here. To downgrade, download the version you want from the plugin store and choose the install plugin from disk as in the picture below
Upgrading Android Studio version to 4.2.1, KMM plugin version to 0.2.6, creating new KMM project with KMM plugin, the problem can be fixed automatically.
If you don't wanna use Xcode:
Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.
What worked for me was to download the latest Canary Android Studio and setup my KMM project there.
Hopefully soon this will be stable for the next versions
Same as here: https://stackoverflow.com/a/66941077/3117650
Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.
What worked for me was to download the latest Canary Android Studio and setup my KMM project there.
Hopefully soon this will be stable for the next versions

Gradle sync on Android Studio

Regarding Gradle Sync on Android Studio.
what does it do?
Why it is needed?
How to debug it?
where to find docs on the subject?
Projects that compile fine from command line have issues with gradle sync instead. I'm interested in the interaction with the android studio environment, cause it's clearly an operation not needed for the sake of compiling a project.

Android studio doesn't create project structure

I am new to Android studio. I tried to create my first project and there is no project structure only gradle files. What am I doing wrong? I keep getting these files with creation of another new project.
Update SDK via Android SDK Manager. You need all packages in Tools to be installed.
But even after doing so, I can't make it to auto generate resources. So I continue to deal with it...
I found what was my problem. I updated Android studio from version 1.x to 2.x. On official site is written that if you try to install version 2.x into same location Android studio might not work properly and there could be some unexpected behavior.
So just removing Android studio and then reinstaling it, worked perfectly.

Resources