Questions tagged [kotlin]

10071 questions
7

votes
1

answer
274

Views

Build failed after update coroutines to 1.2.0: META-INF/atomicfu.kotlin_module

After update to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.0 android build failed with issue: More than one file was found with OS independent path 'META-INF/atomicfu.kotlin_module' Are there any workaround to make it work?
anber
3

votes
1

answer
89

Views

Recreate job after another job is completed

I have the following situation: job1 and job2 go to the server in the same time and both of them came back with status 401, which means that my token access has expired and I need to make a refresh. I start job3 which came back the new token. In this case, I have to recreate the job1 and job2 with t...
Gabrielle
1

votes
0

answer
49

Views

Parse - offline object crash

I'm having some trouble with Parse SDK for Android. I can't reproduce the issue, but from the logs I know it happens when I call bookParse.saveEventually { ex -> ... } The exception is: Attempted to fetch an object offline which was never saved to the offline cache. The main problem is that before I...
Adrian Coman
1

votes
2

answer
128

Views

LiveData with multiple sources of different types

I currently have a project that contains a list of MyItem, and using Firebase/LiveData. It's structured into groups, and each group has items. I want to be able to update this list if any of the following happen: An item is updated (on the backend through Firebase) A filter is changed (a separate ta...
Advice-Dog
1

votes
0

answer
41

Views

Performance optimizations of LineBreakMeasurer

I am currently writing a text block with syntax highlighting in OpenGL and to layout my lines correctly with line wrapping I am using AWTs LineBreakMeasurer. The visual results are perfect, the performance is OK, however I was wondering if there are possibilities to make it a bit faster. Currently i...
Cromon
1

votes
0

answer
144

Views

kotlin-js convert string to another encoding

I parse site and get String in windows-1251 encoding. I want print it to console for example. But in console I see incomprehensible symbols. How I can convert windows-1251 String to UTF-8 or how I can print normal string using kotlin-js ?
Artiom
1

votes
1

answer
571

Views

Kotlin (Maven) - executable JAR without source files

I wanted to create an executable kotlin jar file with maven. But somehow the kotlin source files are packed with the jar. I configured the kotlin plugin and the maven assembly plugin to create a self-contained jar. Here are the dependencies and plugins of my pom: . 1.8 1.8 1.2.0 0.20 server.RunKt ju...
mrdlink
1

votes
1

answer
259

Views

Using Retrofit + OkHttp + Gson the api returns html though postman return json

I tested my api in postman and it returns json just a plain get api baseurl/ecom-services/api/mobile/tasks/user/tokenhere_/upcoming but on Android @GET('mobile/tasks/user/{id}/upcoming') fun jobList(@Path('id') id: String): retrofit2.Call this returns an html onError returns this: java.lang.Illeg...
renzvader
1

votes
1

answer
1.1k

Views

Kotlinc command line error

I follow this (https://kotlinlang.org/docs/tutorials/command-line.html) instruction. I set the environment variable (windows 7) to bin directory run 'kotlinc' at the command line i get the following error (I even navigate to the bin directory from the command prompt) Error: Could not find or load ma...
Daud Oladipo
1

votes
2

answer
256

Views

Kapt exception when creating XML file

I am working in Kotlin on Android Studio. The project compile and works perfectly, but then when I try to create a new XML file, I keep getting a kapt exception 'Exception while annotation processing'. I try to create XML file by right click on res folder -> New -> Layout Resource File, and I also t...
Elynad
1

votes
0

answer
359

Views

How can I use ORM database “Active Android” by Kotlin on Android Studio?

I try to use Active Android (ORM DataBase) in My Kotlin Project But when I save the EditText input , my program always crashes! All program codes are available in Gitlab.com Where is the problem with my codes? and if you know the sources of education in this regard, tell me to come MainActivity.kt ....
Majid ahmadi
0

votes
1

answer
15

Views

Why does lateinit work on Object type but not primitive type?

This answer says that Object types use the null value on lateinits of Object type. Can someone elaborate on this? What do they mean by 'uses the null value'? Furthermore it says 'For primitive types, there is no such value' - why is there no
Zorgan
1

votes
0

answer
8

Views

How do I turn on assertions for Android Studio with Kotlin

I cannot get assert to work under Android Studio 3.3.2 using Kotlin (Windows 10). I've read/researched a bunch and this is what I've done: Help | Edit Custom VM Options... at which point I was presented with a dialog saying File 'C:\Users\me\.AndroidStudio3.3\config\studio64.exe.vmoptions' does not...
Free Dorfman
1

votes
0

answer
165

Views

ViewPropertyAnimator's alpha animation does not work

I use ViewPropertyAnimator for creating alpha animations. Both withStartAction() and withEndAction() work great, alpha values changed, but they changed in no time, looks like there is no animation, just changing values. Where is a mistake? private fun run(millisecondsPerPixel: Long) { //millisPerPix...
panda_eye
1

votes
1

answer
591

Views

Variables not initialized properly when initializing it in an overriden abstract function called from constructor or init block

I hit a problem with some Kotlin code and I found out it was related to calling a method that assigns some variables from an init block (or a secondary constructor for that matter, either reproduces the problem). MCVE: abstract class Shader(/*Input arguments omitted for the sake of an MCVE*/){ init{...
Zoe
1

votes
0

answer
501

Views

Android Clean Architecture: Repository pattern concerns

I am currently developing an Android app, trying to follow the Clean Architecture guidelines. The app retrieves the latest news headlines and lets the user customize their news feed. In my domain layer, I have the following repository interface: interface ArticleRepository { fun getTopArticles(requ...
Elias
1

votes
1

answer
100

Views

modify outer class through anonymous inner object in kotlin

I'm writing my first Android app in Kotlin. What I'm trying to do is to issue an HTTP request (Volley) in order to fetch some data which shall be written into the object's properties. That works fine so far until the Volley response listener is left. Afterwards the properties are back to null. Thi...
bob3000
1

votes
0

answer
291

Views

KDoc Annotations not rendered in Dokka generated HTML

I am currently testing the Dokka documentation and some of the annotations I have made are not being rendered. Here are my findings: Classes don't show @sample, and html tags , : See SimpleCalculator class documentation If a description was under an html tag, it will not show: See enum class OPERA...
Paula Kristin
1

votes
0

answer
178

Views

Kotlin js/native map object via Types

I want to collect some object in a Map, keys are object type (in JVM and kotlin-java it's Class). but what can I use for kotlin native and kotlin js codes. Example Kotlin-JVM code: val pool = HashMap>() val testVal = pool[Test::class.java] as Test val stringVal = pool[String::class.java] as String p...
Hossain Khademian
1

votes
0

answer
97

Views

Camera intent not working: it enters catch block and says “could not create file!”

problem in opening camera intent in android import android.app.Activity import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.os.Bundle import android.os.Environment import android.provider.MediaStore import android.support.v4.content.Fil...
Master Guy
1

votes
1

answer
372

Views

Handling click events in android kotlin: setOnClickListener only works when double-clicked

I have a button in a DialogFragment to go back to another activity. But it only works when double-clicked. I'm running out of ideas. In my XML file, I've already tried the following (combined in different ways, but none of them worked) My whole fragment XML file As for my DialogFragment, I've tried...
Lenasimov
1

votes
0

answer
132

Views

Kotlin Parcelize Exception API < 21

I am using Parcelize in kotlin. Whenever I run my app on an API level below 21 I get the following exceptions: W/dalvikvm: VFY: register1 v5 type 17, wanted 5 W/dalvikvm: VFY: register1 v6 type 17, wanted 5 W/dalvikvm: VFY: rejecting opcode 0x76 at 0x0020 W/dalvikvm: VFY: rejected L$Creator;.creat...
jlively
1

votes
0

answer
205

Views

Can't make the vert.x + kotlin + gradle hot redeploy works

I just start looking into vert.x and downloaded an example restful project from https://github.com/vert-x3/vertx-examples/tree/master/kotlin-examples/web. According to the readme, it should be able to auto-reploy when there's any file change, but it doesn't seem to work. No matter how many times I c...
Rick Lee
1

votes
1

answer
512

Views

Unable to resolve dependencies for assembleAndroidTest task with Android Gradle plugin 3.0.1

I'm updating our project to use Gradle 4.1 and Android Gradle plugin 3.0.1. I have updated our dependency configuration to the new configuration and the project successfully compiles. However, there are lots of unresolved dependencies (incl. Kotlin standard library's top-level functions) when compil...
Javad Sadeqzadeh
1

votes
2

answer
406

Views

android studio 3.0.1 and kotlin v1.2.10-release-Studio3.0-1 got issue

I am using android studio 3.0.1 and I was going to use Kotlin. I wrote some simple code and when application runs the android studio shows me below error: Error:Gradle: A problem occurred configuring root project 'Firstapp1'. Could not resolve all files for configuration ':classpath'. Could not reso...
pouria barani
1

votes
3

answer
383

Views

How to mock the same method multiple times use mockito

I have a method that needs to be called multiple times, and I can return the same result in the test case, I invoke when use for loop, but is there more simple way to do this? val ONE_DAY_FORMAT: SimpleDateFormat = SimpleDateFormat('yyyy-MM-dd') val tempCalendar = Calendar.getInstance() for (i in (0...
littlegnal
1

votes
0

answer
432

Views

How to package kotlin native library so it can be used in android and iOS projects?

I would like to develop api calls (networking) in kotlin (native) and use the same code/lib in android and iOS project. I plan to use this lib: https://github.com/kittinunf/Fuel Is this possible? How to build iOS framework and android lib (aar) from the same kotlin code? Which IDE/tools are the bes...
DixieFlatline
1

votes
1

answer
58

Views

TextClock in AppWidget not responding to any function calls

I'm working on an information widget for the LG V20/V10, to run in the second screen (very easy to add one: just set your category to 36864/0x9000). Currently, I have a battery view and a TextClock in the RemoteViews layout: In my code, I have these functions, which get called from onUpdate() for ev...
TheWanderer
1

votes
1

answer
115

Views

Dokka source links not created

I'm beginning development on a new library and I want to start the project right with the project setup to generate API documentation using dokka. I'm using gradle as a build tool and I've added the following to my build.gradle file: buildscript { ext.kotlin_version = '1.2.10' ext.dokka_version = '0...
Mustafa Ozturk
1

votes
1

answer
362

Views

Force youTubePlayerFragment orientation

I have a app which only allows portrait orientation. I would like to force the youtube video to be set to landscape/horizontal orientation without going full-screen. I have tried rotating the fragment that contains the video, which works to an extent (the container takes up the shape of landscape,...
Matt_O
1

votes
0

answer
209

Views

Converting html string to pdf or image in Android

I have a html string and i want to convert this to pdf or image file in Android. Is there a way to do such a thing in Android or is there anyone who has done something like this before? Thanks.
emr
1

votes
0

answer
359

Views

how to get errors from URL.readText() when file not found using kotlin

When I don't have internet on my phone or when the URL does not exist this method not doing anything neither crash nor stop searching. I tried this : doAsync{ val json:String json = try { URL('http://10.0.2.2:8888/bac/orient.php?ort=1').readText() }catch (e: IOException){ e.printStackTrace() '' } u...
Ismail ackerboy
1

votes
0

answer
618

Views

lateinit property presenter has not been initialized with EasyMVP, Robolectric and Kotlin

I have problem while trying to use Robolectric to test activity which is using EasyMvp. All of the classes are written in Kotlin. This is beginning of an activity: @ActivityView(layout = R.layout.activity_access, presenter = AccessPresenterImpl::class) class AccessActivity : BaseActivity(), AccessVi...
Jakub Anioła
1

votes
0

answer
472

Views

Idiomatic way to read a binary file with Kotlin?

I'm learning Kotlin and need to read a large binary file with carriage return (0x0d) block delimiters. Is there a more idiomatic method for this example in Kotlin? fun main(args: Array) { val bis = File(args[0]).inputStream().buffered() val buf = ArrayList() while(true) { val i = bis.read() if (i <...
jamesallman
1

votes
0

answer
224

Views

jmethodID was NULL for a method with Kotlin

I am using a native library and having the exception below even though the method exists. I have a nativeInit function that is also exported to MapController and it works as expected. However, the nativeLoadScene method causes an error. JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL in call t...
dgngulcan
1

votes
0

answer
337

Views

View not updating after first time triggering LiveData when using background job in Android

I'm building a debt application in Android using Dagger 2, Room and MVVM. My problem lies with the reactivity of my main view, where a list of debts are shown and you can tick them off. When this activity is launched all the debts are loaded correctly, however when I insert a new debt the view is no...
César Alberca
1

votes
0

answer
80

Views

Kotlin file Opening from Jar instead of Project : IntelliJ

Currently, I am working on a multi-module project, wherein I have started facing an issue, for one of my modules, when I navigate to src->package path and then open a kotlin file (*.kt), as soon as I click on 'Scroll from Source', it shows that the file is loaded from one of the jar in m2 repo. I ha...
Vivek Gupta
1

votes
0

answer
160

Views

Getting Task not Serializable while trying commit Kafka offsets in Spark which broadcast variables

I've written Spark jobs that reads from Kafka and commits offsets manually. It worked fine but since I introduced broadcast variables, I get serializable exceptions because it tries to serialize KafkaInputDStream. Here is a minimal code showing the problem (the code is written in Kotlin but I believ...
Reith
1

votes
0

answer
96

Views

Rectangle Packing - Subset

I'm working on an algorithm that figures out how to pack rectangles into a larger rectangle. I am aware this is similar to the rectangle packing problem but my particular problem has a few quirks; namely the rectangles that I'm fitting only have a defined height, the width can (and should) vary such...
Thomas Cook
1

votes
1

answer
79

Views

kotlin Native Unknown Host Target

I have created a new Hello World Kotlin Native project in CLion IDE but i am getting. kotlin native unknown host target error in. if (NOT KONANC_TARGET) if (APPLE) set(KONANC_TARGET macbook) elseif (UNIX) set(KONANC_TARGET linux) else () **message(FATAL_ERROR 'Unsupported host target')** Because I a...
Hammad Tariq

View additional questions