Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Android Studio doesn't understand SharedCode module in mpp-iOS-Android #96

Open
r3h0 opened this issue Nov 8, 2018 · 9 comments
Open
Assignees

Comments

@r3h0
Copy link

r3h0 commented Nov 8, 2018

The mpp-iOS-Android doesn't quite work in the latest Android Studio. It builds without errors, and I am able to run it on an Anrdoid device, but the common code can't be edited inside Android Studio. Right now, I'd have to edit the Kotlin source in a basic text editor.

The attached screenshot shows how the SharedCode_commonMain doesn't show the common source files, resulting in the createApplicationScreenMessage function being unrecognized.

image

Steps to reproduce:

  1. Clone kotlin-examples
  2. Open root of mpp-iOS-Android project in the latest Android Studio (v3.2.1 as of now)
  3. Note that the SharedCode_commonMain module doesn't have any source code listed
  4. Open app/src/main/java/com/jetbrains/jonnyzzz/myapplication/MainActivity.kt and note that Android Studio doesn't know where the createApplicationScreenMessage function comes from, so it thinks it's an error
@r3h0
Copy link
Author

r3h0 commented Nov 9, 2018

@jonnyzzz, if there's anything I can help to investigate, let me know.

What I'm doing as a workaround for now is using the "Project" view in Android Studio, which lets me access the commonMain source code. After I build the project, navigating to createApplicationScreenMessage takes me to the decompiled source code. From there, I associate the decompiled code with the commonMain module. Since I'm running on Linux, I still get errors because of the iOS project; I had to "unload" those modules.

I also changed ext.kotlin_version to 1.3.0 and the Gradle plugin version to 3.2.1. I don't know if that made any difference.

Shout out to @PeeJWeeJ for helping me find a workaround.

@jonnyzzz
Copy link
Member

jonnyzzz commented Nov 10, 2018

It does not work for me too. Please follow the issue for Kotlin MPP.
https://youtrack.jetbrains.com/issue/IDEA-202036

I was able to compile the project (no matter there were the errors in the editor), did you?

@r3h0
Copy link
Author

r3h0 commented Nov 12, 2018

That's correct; I can compile the project. The static analysis is limited, but the workaround I mentioned has been helpful.

@RafaelPlantard
Copy link

I'm facing this same issue, @jonnyzzz @r3h0 how did you guys fix it?

@jonnyzzz
Copy link
Member

The original problem with the tooling is not yet fixed. You may watch for the
https://youtrack.jetbrains.com/issue/KT-25941

@RafaelPlantard
Copy link

Thanks @jonnyzzz
I created the project using IntelliJ IDEA and after opened on Android Studio and it worked

@GoMino
Copy link

GoMino commented Jan 29, 2019

For my part, I just needed to add the dependency to the SharedCode module in the build.gradle of the android project.

dependencies {
    ...
    implementation project(':SharedCode')
    ...
}

Then sync your gradle, and your references should now resolve.

@egarc
Copy link

egarc commented May 10, 2019

Misreading the above advice, I instead added implementation project(':SharedCode') to the project's build.gradle file. This created an error, so I removed that line, and gradle rebuilt along with the bin directory. Not sure what I inadvertently did, but if anybody has an explanation, this iOS dev would appreciate it 😄

@egarc
Copy link

egarc commented May 10, 2019

I also ran into where the xcode-frameworks directory wasn't getting created. Running ./gradlew build from the command line seemed to fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants