Kotlin Debugging doesn't start in visual studio code - android

I'm new to Kotlin programming language. so... i have downloaded a few extensions such as Kotlin, Kotlin language,Kotlin Formatter, and when i press F5 it gives an ERROR...just one important question which is, should i use another IDE like intellij ?? because i don't really wan't to spend my time on fixing problems, also my computer can't handle android studio so it's between intellij and Vscode.
Error in the link below:
fun main(args: Array<String>) {
println("Hello World!")
}
that's the image of what i tried to debug + ERROR

I also had a hard time with setting up the debugger, and what worked for me was to checkout a template repository from https://github.com/fwcd/kotlin-quick-start and add the following debug configuration (.vscode/launch.json):
{
"version": "0.2.0",
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}",
"mainClass": "quick.start.AppKt"
}
]
}
As a bonus, Gradle is set up then, and one can build, run, and test the app out of the box.
Prerequisites
In VS Code I have installed the following plugins:
https://marketplace.visualstudio.com/items?itemName=fwcd.kotlin
https://marketplace.visualstudio.com/itemsitemName=mathiasfrohlich.Kotlin
https://marketplace.visualstudio.com/items?itemName=naco-siren.gradle-language
And I have installed the following packages locally:
snap install openjdk
snap install --classic kotlin

Of course you can debug your Kotlin code in Visual Studio Code. No need for IntelliJ or Android Studio.
To enable debugging in VS Code, you should install the Code Runner extension
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
and should have the Kotlin command-line compiler installed and configured in your system as well:
https://kotlinlang.org/docs/command-line.html
See the pages below for further, detailed infos:
https://formulahendry.wordpress.com/2017/05/21/code-runner-supports-kotlin-in-visual-studio-code-now/
https://dev.to/mwrpwr/learning-kotlin-programming-with-visual-studio-code-5e29
https://medium.com/#agavatar/programming-with-kotlin-in-visual-studio-code-1d745d6b4ad1

Yes. You can proceed with intellJ. There is first priority i.e. Android Studio but as you mentioned it can not be handled, so you can use IntelliJ.
The advantage of Intelli J it provide by default support files and libraries for Kotlin Development so you don't need to install external extension.
he Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
For more info please visit official website
https://www.jetbrains.com/idea/features/

Related

Flutter - Set target file base on Android product flavors

Currently I am using Flutter to build my application.
Background
I have followed some guide on building different environments entry files:
https://iirokrankka.com/2018/03/02/separating-build-environments/
which create main_dev.dart and main_prod.dart.
Also I have learnt to build flavor for both iOS and Android:
https://medium.com/#salvatoregiordanoo/flavoring-flutter-392aaa875f36
which now I can use --flavor <FLAVOR> in the command to build different flavor application.
Now I have encountered a problem when I try to combine two skills.
Target Result
Below is what I would like to achieve:
development flavor -> main_dev.dart entry file
production flavor -> main_prod.dart entry file
Problem Encounter
in iOS side, I can target the entry file in .xcconfig file like following:
// ios/Flutter/development.xcconfig
#include "Generated.xcconfig"
FLUTTER_TARGET=lib/main_dev.dart
I know I can add -t lib/main_dev.dart after flutter run command.
However I would like to ask if there is any solution to set
the flutter target file in Android side inside flavor config?
Appreciate for any help.
I would like to ask if there is any solution to set the flutter target
file in Android side inside flavor config?
I don't know the equal of FLUTTER_TARGET for Android flavor. I would to like to learn that too.
But, flutter run -t is not the only option here. When you open a Flutter project (the root project) with Android Studio you will have a default run/debug configuration like below:
When you click Edit Configurations below screen will appear:
There you can set Build flavor and Dart entrypoint. Obviously, you can create multiple configurations for each flavor.
Reference: https://cogitas.net/creating-flavors-of-a-flutter-app/
So, that's a solution for Flutter in Android Studio. For VSCode, I have a workaround. I'm using -t parameter. But I have it automated by VSCode. Under .vscode/launch.json I have configurations like below:
"configurations": [
{
"name": "GoodOne",
"request": "launch",
"type": "dart",
"args": ["--flavor",
"good",
"-t",
"./lib/main-good.dart"
]
},
{
"name": "BadOne",
"request": "launch",
"type": "dart",
"args": ["--flavor",
"bad",
"-t",
"./lib/main-bad.dart"
]
}
]
With this, you can run your flavors by just pressing F5 and choose your config at the upper-left corner.
Again, this is not an exact answer to OP's question, but some workarounds.

Prism Xamarin.Forms monoandroid81 Add a reference to "MonoAndroid

I keep getting this error. (I'm using Android v8.1 and Prism default template)
Severity Code Description Project File Line Suppression State
Error Your project is not referencing the "MonoAndroid,Version=v8.1"
framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks"
section of your project.json, and then re-run NuGet restore.d#
PrismHelloWorld.Android
So I went into my project.assets.json and change the "monoandroid71" to "monoandroid81"
"originalTargetFrameworks": [
"monoandroid71"
...
"monoandroid71": {
"projectReferences": {
...
"frameworks": {
"monoandroid71": {
I also changed
"projectFileDependencyGroups": {
"MonoAndroid,Version=v7.1": [
and ...
"targets": {
"MonoAndroid,Version=v7.1": {
I hit save and rebuild and it works absolutely fine! The problem is something is editing the json file and turning it all back to 71 and 7.1. I am not sure what is doing it but I will hit built and see the error again, about me needing a reference to v8.1.
Has anyone encountered this issue before?
Go to Android project Options -> Application -> Compile using Android version: (Target framework) and choose Android 8.1 (Oreo). Try different options
I just had the same problem on MvvmCross with Xamarin and I did your solution (changing "monoandroid71" to "monoandroid81" and "v7.1" to "v8.1") but it reverts back after closing and reopening the solution. What I did was do the same thing and do a "Restore NuGet Packages" at the end.
got the same issue, and able to fix it using below option,
Change the target version and rebuild.
I had the same issue, what I did was just restarted VS, and its back to normal
I resolved it by:
Right click Android project => Properties => Application => Compile using Android version => Android 7.1
Clean and Build project => build success, and restart IDE.
Right click Android project => Properties => Application => Compile using Android version => Android 8.1
Clean and Build project => build success
File obj/project.assets.json updated to "MonoAndroid,Version=v8.1"

include.gradle file being generated is causing problems

When building a project I get the following error:
Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
It happens only when using the pro version through the #progress registry. Doesn't happen with the local .tgz pro version.
I noticed the error has to do with the include.gradle file it generates. I read the following article: https://docs.nativescript.org/plugins/plugins#includegradle-specification
It says that when the plugin doesn't have the include.gradle, at build time gradle creates a default one with default elements. When I saw the include.gradle it generated for the plugin it seems to have generated a default one like so:
android {
productFlavors {
"nativescript-telerik-ui" {
dimension "nativescript-telerik-ui"
}
}
}
The include.gradle generated for the local .tgz version of the plugin is like this:
android {
productFlavors {
"F6" {
dimension "nativescripttelerikuipro"
}
}
}
I replaced the default include.gradle with the latter and it got past the error. You can recreate the problem by following these steps:
create a new hello world app
use the command npm login --registry=https://registry.npm.telerik.com/ --scope=#progress to log in if you're a paying customer.
use the command npm install --save #progress/nativescript-telerik-ui-pro to install the plugin
use tns run android
Is there anything I can do to solve this problem? Really need help on this.
My name is Vladimir and I am part of the nativescript-telerik-ui-pro team. Thank you for logging this issue in our feedback portal. We are going to review it as soon as possible and update you regarding its status, but from what I currently see there is some incorrect "parameters" passed to the 'pro' version of the plugin that are going to be resolved very fast.
We apologize for any inconvenience that this is causing.

Xamarin and Travis-ci

I have a simple hello world app that fails to build. I'm getting the following output from the build.
Warnings:
/home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: warning : Could not find project file /usr/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets, to import. Ignoring.
/home/travis/build/chaione/csharptrav/csharp/csharp.Droid/csharp.Droid.csproj: warning : Could not find project file /usr/lib/mono/xbuild/Novell/Novell.MonoDroid.CSharp.targets, to import. Ignoring.
Errors:
/home/travis/build/chaione/csharptrav/csharp/csharp.sln (default targets) ->
(Build target) ->
/home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: error : /home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj: /home/travis/build/chaione/csharptrav/csharp/csharp.iOS/csharp.iOS.csproj could not import "$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets"
What do I need to do get this to build? The solution consist of 6 projects: Core PCL(profile 78), Android, iOS, Android UI test, iOS UI test, UnitTest (using NUnit).
I had an issue like that and moved to https://www.appveyor.com/. Here https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/appveyor.yml you can find a link to appveyor.yml which plays the role as .travis.yml. Please note that you have to have a Xamain license. The credentials are secured in the appveyor.yml file.

How to make Android Studio 1.1 call generateDebugTestSources instead of assembleDebugTest during "Make" instruction?

I have a project with 1,000+ tests running fine with Robolectric. After switching to Android Studio 1.1 when I go to "Run" -> "All Tests" during the "Make" instruction Android Studio calls Gradle's assembleDebugTest instead of generateDebugTestSources .. In my case this makes the build system to start dexing and packaging the test APK which is useless for me since all the tests are JVM tests.
I found this change that might be causing it:
- if (testCompileType == TestCompileType.ANDROID_TESTS) {
+ if (testCompileType != TestCompileType.NONE) {
String gradleTaskName = properties.ASSEMBLE_TEST_TASK_NAME;
if (StringUtil.isNotEmpty(gradleTaskName)) {
tasks.add(createBuildTask(gradlePath, gradleTaskName));
Is there a way to make it configurable on Android Studio? Version 1.0 was working fine.
Thanks!
If someone is interested in the solution according to the new Unit Testing guide:
http://tools.android.com/tech-docs/unit-testing-support
you need to change the test artifacts to "Unit Testing" as describe on step 5. That way when you run all the tests AS will call the new assembleDebugUnitTest task instead of assembleDebugTest.

Categories

Resources