How to configure an iOS Application for Kotlin Multiplatform in Android Studio? - 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

Related

Android Studio 3.1.3 having issues with Constraint layout, Error Failed to find style 'coordinatorLayoutStyle' in current theme

This is the issue i am getting.
Error not rendering issue
i tried all the options available on the web. it is a new installation of studio 3.1.3 and it is happening for every new project as i did not test with any old project as i do not have one.
steps to recreate is to clean installation of android studio 3.1.3 and create a new project. i tried to create multiple projects but same issue.
i tried all the options available on Android Studio 3.1.3 having issues with Constraint layout link but all are failing.
any one let me a studio version name where i will not get this issue. i just wanted to develop a app. and i am not a andriod developer. so these issues are very annoying for me.
Have the same problem. I think it's from Android SDK Platform 28 so I uninstall it, and use Android SDK Platform 27 and it work for me.
To uninstall : Tools> SDK Manager> System setting> Android SDK> Show package detail(little
box on the right below corner)> Put out the check sign from Android SDK
Platform 28 > apply and try new project.
Note : Sorry for bad English.

How to open an existing Flutter Project in Android Studio

I might sound noob here but I can't see a clear way of opening existing Flutter Project in Android Studio 3.1.2.
I checked this but it didn't work. So I want to know if there is a standard IDE way of doing this? I also can't find any docs clearly mentioning it. Do I need to install a 3rd party plugin?
After opening it as an Existing Android Studio Project, I get the following error:
The error is solved by running Get Dependencies. Is it a normal behavior?
Install Flutter plugin for Android studio: https://flutter.io/get-started/editor/
Open Android Studio
Open existing Android Studio project by using one of below methods:
EASIEST WAY: Drag your project folder and drop to Android Studio.
Other ways:
What works for me was to open existing Android Studio project like mentioned above, and then go to menu
Tools -> Flutter -> Flutter Clean
Then configuration window will open and ask you to locate flutter sdk. After locating the sdk, click OK and then the flutter functions will be available (Pub buttons, runs menu). After that you can proceed to get the dependencies (pub get).
It's basically cleaning the project folder of previous setting(s) which might conflicting with the system (android studio). But that won't happen if you get the project from source repository because all of the junk files wont be in the project folder.
The quickest way on macOS is
open -a Android\ Studio android when you are in the root project directory.
Alternatively, if you use the jetbrains toolbox, you can enable "Shell Scripts" in its settings. This will create a binary in the folder of your choice, so you have to add this folder to your PATH. Then, you can use studio . inside the Android folder, or studio android in the flutter project. The benefit of this, is it also works with other Jetbrains products (e.g. charm project_dir or clion project_dir. Unfortunately this method glitches out (for pycharm at least).
Looks like Android Studio can't load Android Application module from Flutter project automatically. I also have same problem, so in my situation Gradle can't be found, because of lack of Android project.
There's important note from official site:
Important: Do not use the New > Project from existing sources option for Flutter projects
I suggest, same is for Open option.
Just Open your project as normal, and then in [Android Studio > Preferences > Languages&Frameworks > Flutter > Flutter SDK path] select the path where you downloaded & unpacked Flutter SDK.
I know it's already late, but you can open an existing Flutter project in Android Studio by following these steps (make sure you have already installed Flutter & Dart plugin and Flutter SDK):
Click Open from File menu in Android Studio,
Go to the path of the project,
Click Open from the dialog,
When the project opens in Android studio, it will show an error of packages and dependencies. So, click on Get Dependencies on the top. Android Studio will automatically add all the required dependencies and packages.
There is a simple way of doing this in android:
Just Open your project as normal, and on the top right corner, click on Flutter Attach option, and voila!
See Attached screen grab!
Usually you can open your Flutter project in Android Studio simply when you right click on the android folder > Flutter > Open Android module in Android Studio but sometimes this option could be disabled, check this answer to enable..

Does Android Studio support Code completion for C/C++?

The code completion is fine on Android Studio java project. But I want to use Android Studio to edit some existing C file(.cpp).
for example, if i have declared some function, then i type the function in other section. But the android studio doesn't show up the code suggestion or some debugging.
Can Android Studio support Code completion for C/C++ like this:?
Yes it does, as long as the project is setup to use the NDK and the C/CPP sources are included in the project.
Try pulling the ndk sample repo and try opening one of the projects.
If you have a java project and want to edit some arbitrary C or C++ source, then no. It does not have enough information about the source file, include paths, compiler etc...
If your project uses Android.mk to build, it will be a bug of Android Studio. I have been reported.
Android.mk project cannot show code completion for cpp.
It seems that old version of Android Studio does not support code completion of jni native build (with Android.mk as configuration file), and that should already be fixed now.
But if you are using CMake in your project as external building tool and code completion still does not work, It's probably because you have more than one version of cmake installed. You can try to remove extra ones from SDK manager and restart Android Studio, it should work.
To see installed CMake version, you can open the SDK manager and check the 'show package details' on the right bottom. You can view cmake tools installed with different versions.

VS2012 with Xamarin 3, frezes when adding MvvmCross 3.1.1 nuget package to android project

I've recently upgraded the Xamarin to the new version (Xamarin 3).
After this update, everytime I try to add the MvvmCross 3.1.1 nuget package to an android project, the VS2012 freezes (In the dialog window when he's trying to resolve and add the references).
Can this be an issue with the nuget package?
I haven't seen anyone complain about this, so I'm more inclined to say that there may be something wrong in my xamarin instalation, but first I would like to know if anyone else had this problem...
I had a similar problem with a Xamarin update. Make sure you have the latest Android SDK Tools and Android SDK Build Tools installed. The reason it hangs is that MvvmCross adds resources to your project and if you don't have the correct resource compiler from the SDK, it fails and hangs.

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