简体   繁体   English

开发Android应用程序时使用外部库

[英]Using external libraries when developing Android application

I want to implement an application that uses image recognition system IQEngines. 我想实现一个使用图像识别系统IQEngines的应用程序。 I'm using eclipse for that. 我为此使用eclipse。 I'm trying test codes IQEngines provide but the result I'm getting is that "File apple.jpg does't exist" 我正在尝试IQEngines提供的测试代码,但得到的结果是“文件apple.jpg不存在”

I'm not sure where the problem lies. 我不确定问题出在哪里。 It seems like I imported all relevant jar files so the code should work. 似乎我导入了所有相关的jar文件,因此代码应该可以工作。 In eclipse I changed Main method into onCreate so that the activity can run Does anyone have a clue?? 在eclipse中,我将Main方法更改为onCreate,以便活动可以运行有人知道吗? Has anyone ever used IQEngines? 有没有人使用过IQEngines?

There's javaiqe.java that javaiqe_test.java is using but it's very long so I don't want to attach javaiqe_test.java使用的是javaiqe.java,但是它很长,所以我不想附加

 package com.Camera;

import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.iqengines.javaiqe.javaiqe;
import com.iqengines.javaiqe.javaiqe.IQEQuery;

/**
 * IQEngines Java API
 *
 * test file
 *
 * @author 
 */




public class javaiqe_test extends Activity{

     @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            TextView tv = (TextView) findViewById(R.id.resultImg);

            final String KEY = "64bc6a7fd77643899d3af8b305924165";
        final String SECRET = "c27e162ea7c24c619f850014124598";

        /*
         * An API object is initialized using the API key and secret
         */
        iqe = new javaiqe(KEY, SECRET);
        uploadObject();

        /*
         * You can quickly query an image and retrieve results by doing:
         */

        File test_file = new File("apple.jpg");

        // Query
        IQEQuery query = iqe.query(test_file);

        System.out.println("query.result : " + query.getResult());
        System.out.println("query.qid : " + query.getQID());

        tv.setText(query.getResult());

        // Update
       /* String update = iqe.update();
        System.out.println("Update : " + update);*/

        // Result
        String result = iqe.result(query.getQID(), true);
        System.out.println("Result : " + result);


        // Upload
        //uploadObject();

    }

    /**
     * Sample code for uploading an object
     */
    public static void uploadObject() {
        // Your object images
        ArrayList<File> images = new ArrayList();
        images.add(new File("res/drawable/apple.jpg"));


        // Object infos
        String name = "Computational Geometry, Algorithms and Applications, Third Edition";

        // Optional infos
        String custom_id = "book0001";
        String meta = "{\n\"isbn\": \"9783540779735\"\n}";
        boolean json = false;
        String collection = "books";

        // Upload
        //System.out.println("Upload : " + iqe.upload(images, name, custom_id, meta, json, collection));
        System.out.println("Upload : " + iqe.upload(images, name));


    }

    private static javaiqe iqe = null;

}

If you're sure you've imported everything you need, then it could be useful, if you clean your eclipse project, and rebuild it again. 如果确定已导入所需的所有内容,那么如果您清理eclipse项目,然后重新构建,则它可能会很有用。 Other reason might be - that you've forgotten to 'redeploy' your application. 另一个原因可能是-您忘记了“重新部署”应用程序。

This might be helpful too. 也可能会有所帮助。

Good luck! 祝好运! Probably you've missed some minor detail - I've been using external jars without any problems in Android projects. 可能您错过了一些小细节-我一直在使用外部jar,而在Android项目中没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM