Using flutter module in kotlin multiplatform app - android

I created an application with kotlin multiplatform and I want now to use flutter to develop the UI once. I followed the tutorial to integrate flutter in an already existing Android app and I choose option B to compile everything in one step.
The first trouble is including the Flutter module as a subproject in the host app: in the kotlin multiplatform project, I have to rename the settings.gradle.kts to settings.gradle. Then I have another error I can't get rid of: Caused by: java.lang.AssertionError: Project :app doesn't exist. To custom the host app project name, set 'org.gradle.project.flutter.hostAppProjectName=<project-name>' in gradle.properties.. Expression: (appProject != null). Values: appProject = null
I understand what the error means: with kotlin multiplatform, the project is not called app but the name of the app, in my case MusicTraining. So as mentioned in the kotlin documentation:
Tip: By default, the host app provides the: app Gradle project. To change the name of this project, set flutter.hostAppProjectName in the Flutter module’s gradle.properties file. Finally, include this project in the host app’s settings.gradle file mentioned below.
So, in the flutter module's gradle.properties file I tried to add the lines:
flutter.hostAppProjectName="MusicTraining"
flutter.hostAppProjectName=":MusicTraining"
I still have the same error.
I tried with vscode to change all instances of :app to :MusicTraining but nothing works. I still have the same error.
As the error mention, I tried to add the line
org.gradle.project.flutter.hostAppProjectName="MusicTraining"
org.gradle.project.flutter.hostAppProjectName=":MusicTraining"
in the flutter module's gradle.properties file, but still the same error.
How can I integrate a flutter module in a kotlin multiplatform app?

Try to add flutter.hostAppProjectName=MusicTraining into gradle.properties file with both Flutter module and you root project.
Notice: run you native application, If you run main.dart, you still get this error
I face the same problem, this works for me.

If you already have a Kotlin multiplatform project, I'd use Jetbrains Compose multiplatform instead of Flutter. Compose is very similar to Flutter and you would avoid the technology split.
https://www.jetbrains.com/de-de/lp/compose-mpp/

Related

How to create an android project using Kotlin DSL and buildSrc

I have searched a lot and I can only find guides or results that tell you how to migrate an existing Android project that uses the normal groovy layout that is default into a project with Kotlin DSL and buildSrc. I was wondering if there is a way to create an android project that was rather than having to migrate it.
The only thing I can think of is someone creating a github action for you to fork, but I would rather be able to create one from Android Studio itself.
Using the terminal in Android Studio, navigate to a new folder (this is where the project will be saved) and type the following:
gradle init --type kotlin-application
Press [CTRL + ENTER] to have Android Studio process the command. The run tab at the bottom should open and will ask which DSL you would like to use for the project. Click the area after this text and enter 2 for Kotlin. Then enter your project name and package name.
I would still recommend using the standard GUI interface within Android Studio to create a project and manually convert the files, as the method above does not create all the standard files that Android Studio does. In other words, you will likely find it more time consuming using the Build Init Plugin.
reference: Build Init Plugin

Not able to add dependency to android project in flutter

Hello I am new to flutter and i want to do native function calls using flutter, i wrote an sample native code app and it is working as expected. Now i want to use some packages on my android code, which is platform specific.
I have added my dependcies in my build.gradle file and it the gradle build is success,
But i cannot use the package there,
say for example: i have added the dependency for the com.squareup.okhttp3:okhttp:3.4.2 and gradle build is success and now icannot access their methods and other stuffs. Please let me know to what to do with it. Thanks in advance.enter image description here
Finally it worked, i opened the android project as an new android project in android studio which resolved the issue.

How can I run kinetise(framework) source code in Android studio?

I do one template project from "kinetise"(framework) and downloaded the android source code,
but not able to run this source code in android studio for editing.the downloaded source code was combining of javascript files also.
https://www.kinetise.com/user/dashboard
In kinetise while build code for Android and iOS both it will provide a template in which there are too much irrelevant code you have to search your required file by your own and done changes accordingly.
You must have to share your error here.
Most common error:
Error:Project :Kinetise declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :facebook-android-sdk.

Netbeans 8.1, Gluon Project Android Error

I'm using Netbeans 8.1, with gluon and nbandroid plugins, on Windows 8.1, and when I create a gluon basic project i can't run on Android platform, the error are about ANDROID_HOME, in the last two days I have searched a lot about it but all the tries I have made don't help.
Here is the error:
Caused by: org.gradle.internal.exceptions.LocationAwareException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
Caused by: org.gradle.api.GradleException: ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
I tried the sample project from gluon, and the error still appears, but if I create an Android project (nbandroid, not gluon) and run it, everything is ok.
I see same difference from other questions on the project, when I create a gluon basic project automatically a Android project is created, but i don't see that on a lot of movies i watch on Youtube.
Can anyone help me, please? If more data is needed, I can upload it.
You can have a look at the JavaFXPorts documentation on the prerequisites to get started.
There are several options on how to set ANDROID_HOME. Basically:
Define the androidSdk property under jfxmobile.android in build.gradle:
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/<path to>/Android/sdk'
}
}
Or create a file named grade.properties, and place it in your local gradle folder (C:/Users/<user>/.gradle), adding this property:
ANDROID_HOME=C:/<path to>/Android/sdk
If you use the second option, you won't need to take care of adding it all the time on new projects.
Also you will find this local file added on your NetBeans projects, in a Gradle Home folder:

Need help setting up RoboSpock

I want to use RoboSpock for Testing my android apps, but I am stuck setting up my project. I created an example project which I have added to github.
https://github.com/DerSchimi/RoboSpockExample
This project contains a folder called AppLibrary which is an android-library. The App itself is inside the folder App.
All RoboSpock Tests should go inside the folder AppTests. I have configured everything, but when I try to run my tests I get this error message:
WARNING: no system properties value for ro.build.date.utc
groovy.lang.MissingPropertyException: No such property: AppActivity for class: de.derschimi.app.MainActivitySpecification
at de.derschimi.app.MainActivitySpecification.Should say hello world(MainActivitySpecification.groovy:15)
This is the line of code:
def mainActivity = Robolectric.buildActivity(AppActivity.class).create().get()
Is there anybody out there who is using RoboSpock? Thanks a lot for your help!
The plugin I consider as deprecated. At this moment I'm creating just samples how to enforce gradle java plugin understand the android one. I suggest to browse this project.
https://github.com/pjakubczyk/robospock-sample/tree/master/simple

Categories

Resources