Log in or register to post comments

New project problem

March 17, 2013 - 1:05pm #10

I can run and try ImageTarget project successfully and I can change marker and add my own model correctly. This project run perfect. but now i want to create my own project with different name. I copy the imagatarges project's java classes which are in src folder and also copy res folder for drawables and layouts. Also I add assets folder. After that I create my own xml files and their java classes. After that, i combine them. Also i add the qcar.jar file as referances libiries and jni folder to my project. But when i try to run my project i think that my project does not reach the .cpp classes. Because when start the program my interfaces came but after the some button clicks camera does not open like imagetarget project. How can i solve this problem? (ps:I did ndk build correctly)

New project problem

March 17, 2013 - 1:30pm #9

Hi, have you also renamed  the native functions in your CPP code, so to reflect your new package name and class name ?

As an example, consider the function startCamera defined in ImageTargets.cpp:

 

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv *,
                                                                         jobject)
 
As you can see, the name of the function is made up of several parts:
  • Java_
  • com_qualcomm_QCARSamples_ImageTargets_: this part represents the package name of your ImageTargets java class
  • ImageTargets_: the name of the class from which the native method will be called
  • startCamera: the final part of the name of the function

So, if you have created your own project, probably you are now using your own package name and/or class name;

you will need to reflect those names in the name of the natuve functions in CPP, as explained above.

 

New project problem

March 17, 2013 - 2:44pm #8

I changed all of code like you said but still some errors are continue. I add logcat error message now. What i do wrong?

 


03-17 23:02:26.504: E/AndroidRuntime(26667): FATAL EXCEPTION: main
03-17 23:02:26.504: E/AndroidRuntime(26667): java.lang.UnsatisfiedLinkError: getOpenGlEsVersionNative
03-17 23:02:26.504: E/AndroidRuntime(26667): at org.example.treasurehuntnew.ImageTargets.getOpenGlEsVersionNative(Native Method)
03-17 23:02:26.504: E/AndroidRuntime(26667): at org.example.treasurehuntnew.ImageTargets.getInitializationFlags(ImageTargets.java:366)
03-17 23:02:26.504: E/AndroidRuntime(26667): at org.example.treasurehuntnew.ImageTargets.onCreate(ImageTargets.java:339)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.Activity.performCreate(Activity.java:4531)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.ActivityThread.access$600(ActivityThread.java:139)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.os.Handler.dispatchMessage(Handler.java:99)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.os.Looper.loop(Looper.java:154)
03-17 23:02:26.504: E/AndroidRuntime(26667): at android.app.ActivityThread.main(ActivityThread.java:4944)
03-17 23:02:26.504: E/AndroidRuntime(26667): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 23:02:26.504: E/AndroidRuntime(26667): at java.lang.reflect.Method.invoke(Method.java:511)
03-17 23:02:26.504: E/AndroidRuntime(26667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 23:02:26.504: E/AndroidRuntime(26667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 23:02:26.504: E/AndroidRuntime(26667): at dalvik.system.NativeStart.main(Native Method)

New project problem

March 18, 2013 - 12:47am #7

Ok, the error indeed confirms that it does not find those functions at runtime;

can you copy-paste here these:

- your package name

- the name of your main class, from which you call the native functions (i.e. the equivalent of ImageTargets.java, where you define your activity)

- the definition of a couple of functions from your "imagetargets.cpp" (or whatever it is called in your case)

I just would like to double-check, sometimes the error may be subtle...

 

New project problem

March 18, 2013 - 2:35am #6

Our package's name is: org.example.treasurehuntnew
Main class's name name is: ImageTargets.java (we did not change the main class's name)
These are some definitions:

Java_org_example_treasurehuntnew_ImageTargets_getOpenGlEsVersionNative(JNIEnv *, jobject)

Java_org_example_treasurehuntnew_ImageTargets_setActivityPortraitMode(JNIEnv *, jobject, jboolean isPortrait)

Java_org_example_treasurehuntnew_ImageTargets_switchDatasetAsap(JNIEnv *, jobject)

 

Java_org_example_treasurehuntnew_ImageTargets_initTracker(JNIEnv *, jobject)
{
    LOG("Java_org_example_treasurehuntnew_ImageTargets_initTracker");
    
Java_org_example_treasurehuntnew_ImageTargets_deinitTracker(JNIEnv *, jobject)
 
ps: We added QCAR.jar file as referenced libraries with this path: right click on project name - built path - configure build path - libraries -  add external jars and then find and add qcar.jar. I wrote this because maybe we made a mistake here.

 

New project problem

March 18, 2013 - 3:22am #5

The code looks absolutely OK.

Could you try the following:

Build Path -> Configure Build Path -> Order and Export tab ->   check (tick) the QCAR library, then try to build again and run.

 

 

 

New project problem

March 18, 2013 - 3:39am #4

Yes, it is clicked but still have the same problems.

When I followed the logcat I saw a sentence like that: CheckJNI is off. Is this make problem? I tried my codes with HTC Sensation and the original project (ImageTargets) will work successfully.

And also I only changed ImageTargets.cpp's functions definition in jni folder because i didnt see any other changable functions in other cpp classes. 

New project problem

March 18, 2013 - 3:57am #3

Hi,

the issue might also be related to the module name of your native module;

if you open the Android.mk file (under the JNI dir) you should see a line like:

LOCAL_MODULE := ImageTargets

is it set to "ImageTargets" or something else ?

also, in Java (ImageTargets.java) you should have two lines like this:

 

private static final String NATIVE_LIB_SAMPLE = "ImageTargets";
    private static final String NATIVE_LIB_QCAR = "QCAR";
 
and then also the following code:
 
/** Static initializer block to load native libraries on start-up. */
    static
    {
        loadLibrary(NATIVE_LIB_QCAR);
        loadLibrary(NATIVE_LIB_SAMPLE);
    }
 
In particular, the NATIVE_LIB_SAMPLE string and the LOCAL_MODULE variable should both be set to the same value..
 
could you check ?
 
 
 

 

New project problem

March 18, 2013 - 4:01am #2

I changed local module name with project name so my codes dont work and now my project works fine now. Thank you very much for your help. You are the best.

New project problem

March 18, 2013 - 4:33am #1

You're welcome ;-)

Log in or register to post comments