Android studio中Ormliteconfig文件的编译 [英] compilation of Ormliteconfig file in Android studio

查看:22
本文介绍了Android studio中Ormliteconfig文件的编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能指导我如何在 AndroidStudio 中编译 OrmLiteConfigUtil 文件我是 ormlite 和 Android Studio 的新手.谢谢我检查了下面的链接.但它仍然给出 ClassnotFoundException.

Can anyone guide me how to compile OrmLiteConfigUtil file in AndroidStudio i'm new to both ormlite and Android Studio.Thanks I checked the below link.but it is still giving the ClassnotFoundException.

Checked this but it is still giving the exception

解决方案

The pdf doc of ormLite said:

You will need to run this utility locally on your development box (not in an Android device), whenever you make a change to one of your data classes. This means that right now, this must be done by hand to keep the configuration file in sync with your database classes. To run the utility you will need to use the local Java runtime environment (JRE).

Under AndroidStudio, go to "Run" menu, and select "Edit Configurations...", this will make appear an dialog, click on the green button with the plus sign to add a new Run configuration (should be in the left-top corner of the dialog), in the contextual menu you should select "Application".

Next, click on "Main class" input and select your OrmLiteConfigUtil class. In the working directory input you should select the folder where the "res" android file is placed (in the android studio file structure you should have somthing as ".../app/src/main"). Also, select the checkbox "Use alternative JRE" and select a JRE path of a Java Runtime (for me java 7 of oracle works).

finally, click on "Ok" button to save the changes, and it's ready.

create a "raw" directory in your "res" android folder, do this before of run the config.

To run the new config: right click on the file class (your OrmLiteConfigUtil extended class, the same file that you select in the "Main class" input) and select Run '...'. wait for compiler and that is all!, you should see an config file in your res/raw folder

this is some of code for my OrmLiteConfigUtil extended class:

public class DatabaseConfigUtil extends OrmLiteConfigUtil {

    // put all your database classes in this array
    private static final Class<?>[] clases = new Class[]{Vendor.class};

    public static void main(String[] args) throws SQLException, IOException {
        writeConfigFile("ormlite_config.txt", clases);
    }
}

A screenshot of my configuration runner:

这篇关于Android studio中Ormliteconfig文件的编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆