this is more a theoretical question.
I have an app that is already in the playstore. This app has been working since the year 2017, so it has a lot of old libraries. The goal is to migrate it to kotlin. So, what's more effective to achive this goal:
Migrate file by file to kotlin
Create a new project with same buil.gradle in order to have the same id application. But at this point have another question, if I create a new app with the same id, package name.. can I generate a signed bundle apk with my old credentials?
I'm not pretty sure how to achive this goal. If there is a better I would really appreciate it you can teach me how.
Thanks!
The good point with Kotlin is that it can operate together with Java easily. To rewrite the app completely seems like a lot of work which would need an important reason. You can rewrite file by file and this way keep all functionality working.
If you keep the application Id in a new project, you can update your existing app only if you sign it with your old keystore. These are the two factors that identify your app.
I recently converted an existing application to Kotlin.
Before you start, if you have not done so, I would recommend converting
your application to AndroidX. It will save you a lot of headaches.
**Android Studio Refactor/Migrate to AndroidX**
Note that during the conversion it will miss libraries and dependencies if you use
variables in your gradle file. When that is done and stable then go to Kotlin.
1: Add in the Kolin Libraries
Project Gradle -
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71"
Module Gradle ( **3 library choices - stdlib, jdk7, jdk8** )
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
2: Add the plugins to the Module Gradle
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
3: Converted the java files one by one using the automatic code conversion.
Android Studio - Code/Convert Java class to Kotlin
Note that you will have breakage, mostly around parameter passing. You will need to
become conversant with ( !!, ? and let )
Another thing, as long as you have the Kotlin extension plugin you no longer need
a library for dependency injection. You can pull out all of the Butterknife code.
I would NOT create a new application. I assume you are in bitbucket or github. Why
hang on to the past. Convert and go on with your life.
Hope you find this useful.
Related
I have many java class files written by me for common purposes which I need to use very often in my Android projects. These classes (let's call them 'library') has many static methods in them and I call these methods when I need them in my Android Studio projects without any problem
When I create a new Android Studio project I copy all those library files into the Java folder of my new project. So, I can call them with the syntax like classname.methodname() at any time in my projects (in activities, in other java classes, etc)
The question is that this technic causes many independent library files in each project. This means that, when I have added a new method or changed a method, I need to do the same thing at each library files in each project.
As I am new at Android Studio and I am playing with that at the moment, this might be ok. But in real life, this will be impossible in the near future while I was struggling with many projects.
I am sure that, there should be a way to use file links instead of inserting these library files by copying them into the Android projects. So, making changes in a source library file will affect all projects at once. Something like $I directive in the C type languages...
Is this possible and if yes, how?
Thank you...
One good way would be to create your own library/module in android studio.
Here is a link for that : https://developer.android.com/studio/projects/android-library
And another way would be to create your own JAR file.
I'm facing a problem while developing a library with Android Studio.
The concept is to create one aar (MyLib) which is depends on other aar.
At the end, I want to hide everything from the other aar, and only exposed 'MyLib'.
So I found this tool: 'com.kezong.fat-aar' which give me the ability to create one big fat aar from 'multiple aar'.
Then I have created a ProGuard to only include (-keep) some classes of 'MyLib'.
It works but I can still access to classes defined in the 'multiple aar'.
I've made some online research and I can't find any solution.
Now I wonder if it's even possible to achieve what I want because 'MyLib' should access to the 'multiple aar' (dependencies) but I don't want that the user or client can see them.
Sorry for my bad english...
Do you have any clue or information to help me ?
Thanks a lot.
I have recently been upgrading an old android project, which was using nutiteq sdk.
I begun migrating the classes and functions to the much more recent carto sdk.
While doing so, I have faced a few conflicts or incompatibilities.
But something so simple as a style builder won't resolve for some reason.
I have converted the original style building code to this:
LineStyleBuilder lsb = new LineStyleBuilder();
lsb.setColor(bcolor);
lsb.setWidth(0.02f);
LineStyle lineStyle=lsb.buildStyle();
Android Studio says it cannot resolve setColor and setWidth.
I have imported the correct classes etc, but I get that issue anyway.
Does anyone out there know of what may be going on?
current sdk
old sdk
That should certainly work. The official github sample project (CartoDB/mobile-android-samples) contains basically the same code and works as expected (OverlaysActivity.java).
I just started Android Development yesterday and just finished with my first Activity. On running it, I'm getting errors like
**Error:(4, 37) error: package android.support.design.widget does not exist**
As I never post without it, I've already done plenty of searching on this. Basically, what I've understood is that it couldn't find that Widget Package on my PC. So, do I have to download it? If yes, then how?
People on internet had similar problem with Packages and almost every post has different answer to this. Some say change your Gradle File others say Update your Studio (have done it).
Any kind of explanation or bit of knowledge with the solution would be highly appreciated. I'm a kind of geek who want to get concepts and basics clear. So, it would be great if you include the reason and technicality behind this too with your answer. Thanks. :)
It's a design library for Android apps development and as #Dominique pointed have a look at that page and copy paste that compile 'com.android.support:design:22.2.0' line in your project gradle file and press the sync button. Your project will sync in a few moments and the design library will be downloaded. Now you can use this library and there won't be any errors.
No, in Java "package" is not a "library" or a "piece of software" (like it is in some other languages). Package is what classes belong to - you might think of packages as directories containing Java files (it is a simplification, but it works). In Java libraries are packaged into (usually) "jars" (those jars usually contain classes divided into packages), so what you need to download is "jar".
So, first thing you need to check is: what library contains the package, and configure your IDE accordingly. The package in question belongs, I think to the so called android support library, which you can install using the SDK tool.
I made a small project using Scala (SBT + IntellijIDEA) that provides me a set of classes and other functions that I want to use in Android. I will call this project $core.
So, keeping that in mind I tried to first only use scala. I tried to create an Android Project using android-plugin and I got it.
But what I really want is to use my $core in an Android Project AND expand the $core classes using Java. $core provides an API that I would like more people to use and they probably don't know Scala so Java would be perfect. Besides, I need to go into a safe route with Android. I saw some info that scala takes a lot of time to compile into Android and has some limitations (like with parceblles).
I already tried to use the classes in eclipse with the import class folder option. I even tried to generate a jar so at least I would have a way to run it and no success. Always the NoClassDef error when I try to use one class from the $core. I have tried to import also the scala compiler library, but didn't work out aswell...
Core isn't finished yet and I would like to develop on a single environment that allowed me to debug on the android device. How can I setup all of this?
PS: Changing to eclipse now maybe is better? Never tried android on intellijIDEA and In scala I can't debug over there, at least using ScalaCheck...
Is it possible that you are getting an noclassdeffound error when working with Scala code from java because you didn't add the Scala library to the java project or at least included the party of it that it's used in the Scala code in the jar?
Could you post the rest of the error?
You could package the core to .jar together with Scala library, use Proguard to remove all unused Scala library classes from it, and then use that jar as a regular library.