Discussion:
Problem in running .CPP files & hello-gl2 Sample code on emulator
(too old to reply)
Atul Prakash
2011-04-19 06:29:16 UTC
Permalink
Hello Friends,

Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.

I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.

I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.

So what changes I should do in existing code to run .CPP files with
NDK?

Thanks in advance.

Atul Prakash Singh
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
mic _
2011-04-19 07:39:15 UTC
Permalink
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the Android
team to support it eventually, but there's no timeplan for it that I know
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in Android.mk.
Keep in mind that you'll have to make your JNIEXPORT functions extern "C",
or they won't be found when you load the library.

/Michael
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files with
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Atul Prakash
2011-04-19 08:08:42 UTC
Permalink
Dear Michael,

Thanks for your reply.

Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.

--------------------------------------
My Android.mk file is as follows:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp

include $(BUILD_SHARED_LIBRARY)
-------------------------------------

My hello-jni.cpp is as follows:

#include <string.h>
#include <jni.h>

extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz )
{
return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------

I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.

Regards,

Atul Prakash Singh
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the Android
team to support it eventually, but there's no timeplan for it that I know
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in Android.mk.
Keep in mind that you'll have to make your JNIEXPORT functions extern "C",
or they won't be found when you load the library.
/Michael
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files with
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
mic _
2011-04-19 08:57:42 UTC
Permalink
Post by Atul Prakash
but I think there is some problem with my hello-jni.cpp file.
Do you get an error? If so you should include the error in your post.

/Michael
Post by Atul Prakash
Dear Michael,
Thanks for your reply.
Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.
--------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
-------------------------------------
#include <string.h>
#include <jni.h>
extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz )
{
return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------
I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.
Regards,
Atul Prakash Singh
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the Android
team to support it eventually, but there's no timeplan for it that I know
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in Android.mk.
Keep in mind that you'll have to make your JNIEXPORT functions extern
"C",
or they won't be found when you load the library.
/Michael
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files with
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the Google
Groups
Post by Atul Prakash
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Atul Prakash
2011-04-19 09:20:59 UTC
Permalink
When I run ndk-build command on Cygwin tool, I got error like:

***@ATUL-PC /cygdrive/c/android-ndk-r5b/samples/hello-jni
$ ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : hello-jni <= hello-jni.cpp
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp: In function
'_jstring* Java_com_example_hell
ojni_HelloJni_stringFromJNI(JNIEnv*, _jobject*)':
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp:34: error: no
matching function for call to '
_JNIEnv::NewStringUTF(JNIEnv*&, const char [17])'
C:/android-ndk-r5b/platforms/android-8/arch-arm/usr/include/jni.h:839:
note: candidates are: _jstrin
g* _JNIEnv::NewStringUTF(const char*)
make: *** [/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/
armeabi/objs-debug/hello-jni/hell
o-jni.o] Error 1
Post by mic _
Post by Atul Prakash
but I think there is some problem with my hello-jni.cpp file.
Do you get an error? If so you should include the error in your post.
/Michael
Post by Atul Prakash
Dear Michael,
Thanks for your reply.
Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.
--------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
-------------------------------------
#include <string.h>
#include <jni.h>
extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz )
{
   return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------
I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.
Regards,
Atul Prakash Singh
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the Android
team to support it eventually, but there's no timeplan for it that I know
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in Android.mk.
Keep in mind that you'll have to make your JNIEXPORT functions extern
"C",
or they won't be found when you load the library.
/Michael
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files with
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the Google
Groups
Post by Atul Prakash
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Atul Prakash
2011-04-19 09:39:50 UTC
Permalink
Moreover my Java file i.e. HelloJni.java is like below:

package com.example.hellojni;

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


public class HelloJni extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

TextView tv = new TextView(this);
tv.setText( stringFromJNI() );
setContentView(tv);
}

public native String stringFromJNI();

public native String unimplementedStringFromJNI();

static {
System.loadLibrary("hello-jni");
}
}
Post by Atul Prakash
$ ndk-build
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : hello-jni <= hello-jni.cpp
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp: In function
'_jstring* Java_com_example_hell
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp:34: error: no
matching function for call to '
_JNIEnv::NewStringUTF(JNIEnv*&, const char [17])'
note: candidates are: _jstrin
g* _JNIEnv::NewStringUTF(const char*)
make: *** [/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/
armeabi/objs-debug/hello-jni/hell
o-jni.o] Error 1
Post by mic _
Post by Atul Prakash
but I think there is some problem with my hello-jni.cpp file.
Do you get an error? If so you should include the error in your post.
/Michael
Post by Atul Prakash
Dear Michael,
Thanks for your reply.
Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.
--------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
-------------------------------------
#include <string.h>
#include <jni.h>
extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject
thiz )
{
   return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------
I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.
Regards,
Atul Prakash Singh
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the Android
team to support it eventually, but there's no timeplan for it that I know
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in Android.mk.
Keep in mind that you'll have to make your JNIEXPORT functions extern
"C",
or they won't be found when you load the library.
/Michael
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run various
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc. but
I am unable to run "hello-gl2" sample code on emulator. I am getting
IllegalArgumentException("No configs match configSpec") on emulator
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet, thats why
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples that
have successfully run on my emulator are running .C files with Android
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files with
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the Google
Groups
Post by Atul Prakash
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
mic _
2011-04-19 09:49:31 UTC
Permalink
Post by Atul Prakash
candidates are: _jstring* _JNIEnv::NewStringUTF(const char*)
make: ***
[/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hell

The solution is to use the candidate suggested. I.e.
env->NewStringUTF("your text here");

/Michael
Post by Atul Prakash
package com.example.hellojni;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class HelloJni extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText( stringFromJNI() );
setContentView(tv);
}
public native String stringFromJNI();
public native String unimplementedStringFromJNI();
static {
System.loadLibrary("hello-jni");
}
}
$ ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : hello-jni <= hello-jni.cpp
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp: In function
'_jstring* Java_com_example_hell
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp:34: error: no
matching function for call to '
_JNIEnv::NewStringUTF(JNIEnv*&, const char [17])'
note: candidates are: _jstrin
g* _JNIEnv::NewStringUTF(const char*)
make: *** [/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/
armeabi/objs-debug/hello-jni/hell
o-jni.o] Error 1
Post by mic _
Post by Atul Prakash
but I think there is some problem with my hello-jni.cpp file.
Do you get an error? If so you should include the error in your post.
/Michael
On Tue, Apr 19, 2011 at 10:08 AM, Atul Prakash <
Post by Atul Prakash
Dear Michael,
Thanks for your reply.
Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.
--------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
-------------------------------------
#include <string.h>
#include <jni.h>
extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject
Post by mic _
Post by Atul Prakash
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject
Post by mic _
Post by Atul Prakash
thiz )
{
return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------
I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.
Regards,
Atul Prakash Singh
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet,
thats why
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
Post by Atul Prakash
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the
Android
Post by mic _
Post by Atul Prakash
team to support it eventually, but there's no timeplan for it that
I know
Post by mic _
Post by Atul Prakash
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in
Android.mk.
Post by mic _
Post by Atul Prakash
Keep in mind that you'll have to make your JNIEXPORT functions
extern
Post by mic _
Post by Atul Prakash
"C",
or they won't be found when you load the library.
/Michael
On Tue, Apr 19, 2011 at 8:29 AM, Atul Prakash <
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run
various
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc.
but
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
I am unable to run "hello-gl2" sample code on emulator. I am
getting
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
IllegalArgumentException("No configs match configSpec") on
emulator
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet,
thats why
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples
that
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
have successfully run on my emulator are running .C files with
Android
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files
with
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the
Google
Post by mic _
Post by Atul Prakash
Groups
Post by Atul Prakash
"android-ndk" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google
Groups
Post by mic _
Post by Atul Prakash
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Atul Prakash
2011-04-19 10:17:42 UTC
Permalink
Thanks a lot Michael!!!!!!! It worked....
 >>candidates are: _jstring* _JNIEnv::NewStringUTF(const char*)>>make: ***
[/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/armeabi/objs-debug /hello-jni/hell
The solution is to use the candidate suggested. I.e.
env->NewStringUTF("your text here");
/Michael
Post by Atul Prakash
package com.example.hellojni;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class HelloJni extends Activity
{
   /** Called when the activity is first created. */
   public void onCreate(Bundle savedInstanceState)
   {
       super.onCreate(savedInstanceState);
       TextView  tv = new TextView(this);
       tv.setText( stringFromJNI() );
       setContentView(tv);
   }
   public native String  stringFromJNI();
   public native String  unimplementedStringFromJNI();
   static {
       System.loadLibrary("hello-jni");
    }
}
Post by Atul Prakash
$ ndk-build
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : hello-jni <= hello-jni.cpp
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp: In function
'_jstring* Java_com_example_hell
C:/android-ndk-r5b/samples/hello-jni/jni/hello-jni.cpp:34: error: no
matching function for call to '
_JNIEnv::NewStringUTF(JNIEnv*&, const char [17])'
note: candidates are: _jstrin
g* _JNIEnv::NewStringUTF(const char*)
make: *** [/cygdrive/c/android-ndk-r5b/samples/hello-jni/obj/local/
armeabi/objs-debug/hello-jni/hell
o-jni.o] Error 1
Post by mic _
Post by Atul Prakash
but I think there is some problem with my hello-jni.cpp file.
Do you get an error? If so you should include the error in your post.
/Michael
On Tue, Apr 19, 2011 at 10:08 AM, Atul Prakash <
Post by Atul Prakash
Dear Michael,
Thanks for your reply.
Actually in order to run .CPP files using Android NDK, I modified
hello-jni sample code. I have created hello-jni.cpp(just as actual
hello-jni.c) file. I also added .CPP file to LOCAL_SRC_FILES in
Android.mk, but I think there is some problem with my hello-jni.cpp
file.
--------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
-------------------------------------
#include <string.h>
#include <jni.h>
extern "C"{
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
thiz );
};
JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
thiz )
{
   return (env)->NewStringUTF(env, "Hello from JNI !");
}
---------------------------------------
I am trying to make same application as hello-jni sample but instead
of .C file, I am using .CPP file. Please tell me what changes are
needed to run this hello-jni code to run with hello-jni.CPP file.
Regards,
Atul Prakash Singh
Post by Atul Prakash
Post by Atul Prakash
I think OpenGL 2.0 is not supported on Android emulator yet,
thats why
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
Post by Atul Prakash
hello-gl2 sample is not running on Android emulator.
Yes, it's not supported. It seems like it's the intention of the
Android
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
team to support it eventually, but there's no timeplan for it that
I know
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
of.
Post by Atul Prakash
Post by Atul Prakash
I also want to run .CPP files using Android NDK
There's nothing to it. Just add it to your LOCAL_SRC_FILES in
Android.mk.
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Keep in mind that you'll have to make your JNIEXPORT functions
extern
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
"C",
or they won't be found when you load the library.
/Michael
On Tue, Apr 19, 2011 at 8:29 AM, Atul Prakash <
Post by Atul Prakash
Hello Friends,
Since, last few days I am working on Android NDK. I had run
various
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
sample codes also like San Angeles, Hello-jni, Bitmap Plasma etc.
but
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
I am unable to run "hello-gl2" sample code on emulator. I am
getting
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
IllegalArgumentException("No configs match configSpec") on
emulator
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
but when I run .apk file of hello-gl2 on Android Device, it run
successfully.
I think OpenGL 2.0 is not supported on Android emulator yet,
thats why
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
hello-gl2 sample is not running on Android emulator.
I also want to run .CPP files using Android NDK, all the samples
that
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
have successfully run on my emulator are running .C files with
Android
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
NDK. But in my project I need to run .CPP files.
So what changes I should do in existing code to run .CPP files
with
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Post by Atul Prakash
NDK?
Thanks in advance.
Atul Prakash Singh
--
You received this message because you are subscribed to the
Google
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
Groups
Post by Atul Prakash
"android-ndk" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google
Groups
Post by Atul Prakash
Post by mic _
Post by Atul Prakash
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to android-***@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Loading...