Category: "Android programming"
Error: navigation.json (The system cannot find the path specified) in Android
Recently, I upgraded my android studio to 4.2.1. Then I found all of my projects are not working, I got this erro rnavigation.json (The system cannot find the path specified). Even I created a blank activity project, I got the same error. Therefore, somethings. I tried to switch to lower sdk version, that is still not working. Finally, I found out I put my project in an external disk which is using ex3 format. So that, I can use it in my pc and mac. Is the disk format causing problems? Then I moved my project to the main disk which is using NTFS. Then that is no problems, strange
RecyclerView only show one element
There is not listview in more modern Android SDK. The replacement of this is RecyclerView, that is more flexible, you can set the layout manager, such as LinearLayoutManager or GridLayoutManager, even you can build your own. But that is more powerful, then that is harder to use. The first program I built, I found it only shows the first element. Then I found in the layout resource file of list adapter, the root element cannot set the height to be "match_parent", if you set "match_parent", the first element will be occupied the whole list, then no room for another elements. So the solution is to the height to be the fixed value or "wrap_content.
Android Orm - Room
There are a lot of ORM for Android. Previously, I have used Ormlite. That is quite good. I got a new personal project of Android App. This is a good to look around new framework I can use. I found Google has their ORM layer. That is not form the standard SDK. This ORM is from the Android Architecture Components. That is quite modern, and similar with others. It used annotations like this to define the mapping
Code
@Entity(tableName = "people") | |
public class Person { | |
@PrimaryKey(autoGenerate = true) | |
public int id; | |
public String name; | |
| |
public int eventId; | |
} |
But the Dao is a strange
public interface DrawingEventDao {
@Query("SELECT * FROM drawEvents")
List loadAll();
}
Because it is a ORM of sqlite. You still need to write the SQL like this. That is the things I do not really like. Maybe I have been LINQ for too long. That is not easy to go back the SQL. But that is still much better than connecting with Sqlite
[Android] OCR with Google ML Kit
Recently, I am playing with OCR with Google ML Kit. A few years ago, I wish OCR in my mobile app, I want to extra some text from the images. That was very very hard to do. Either I need to use some opensource projector in a web server, and the app will post the image to my web api to do OCR. Or I need to buy some expensive libraries to do that. But Now, I can use Google ML Kit to do that. I just need to import library in gradle. And then I need to create an instance of TextRecognizer. Finally, I need to call a method with the image to do the OCR. I can use do that on the device or with CloudAPI. If I choose to do that on the device, that is completely free. Even I use the cloud API, I got first 1,000 users are free. That is a good deal. That is a good choice for an indie developer as myself
Error:Could not determine the class-path for interface
Last weekend, I started to migrate my old projects to the latest Android Studio. That is not a smooth process, first error I got is "Could not determine the class-path for interface com.android.builder.model.AndroidProject". I believe that caused by the old grade. I got a tip smart from Android Studio saying I should upgrade the version from 0.22 to 2.3.0. So I modified the classpath in the build.gradle file
classpath 'com.android.tools.build:gradle:2.3.0'
Then I still got the same error. After I did some research on the internet. I found to upgrade the gradle. I need to change gradle-wrapper.properties too.
distributionUrl=http://services.gradle.org/distributions/gradle-3.3-all.zip
That is to get the latest package.
Reference:https://stackoverflow.com/questions/42777321/could-not-determine-the-class-path-for-interface-com-android-builder-model-andro