2013年9月5日星期四

Does anyone get the android JNI? javah always able to find classes.

 This post last edited by the lcb on 2011-09-18 18:15:56
in windows and ubuntu take a development environment , respectively , with the javah command always fail, and how to do ? Command line window prompts below.

Microsoft Windows [ Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
< br /> d: \ BACKUP \ workspace \ helloworld \ bin> javah com.simon.HelloworldActivity
error : Can not access android.app.Activity
find android.app . Activity class file

------ Solution ------------------------------- -------------
Why not NDK?
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/
------ Solution ---------- ----------------------------------
what you are JNI ah. how also find android.app.Activity go. .
The class specifically created a jni try
------ Solution ---------------------------- ----------------
javah-d -classpath
---- - Solution --------------------------------------------
this problem should be your path to the path that you must question it wrong ; directly to you that you compiled . class in the same directory with the project is with the home directory at the same level it should be all right
------ Solution -------------------------------------- ------
recommend using the following two commands:
d: \ BACKUP \ workspace \ helloworld \ bin \ com \ simon> javac HelloworldActivity.java
d: \ BACKUP \ workspace \ helloworld \ bin \ com \ simon> javah-jni HelloworldActivity

------ For reference only -------------------------------- -------
javah-jni co.aaf.class
------ For reference only ------------------ ---------------------
javah-jni com.example.HelloWorld

com.example Yes, you package

If the path is : / home / user / com / example / HelloWorld.class

then the / home / user execute javah
------ For reference only -------------------------- -------------



NDK I have installed , but javah command looks like , and it has nothing to do NDK ?
is a simple empty Android project ah :
package com.simon;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class HelloworldActivity extends Activity {
    private static final String TAG = "HelloWorld";
        static {
                System.loadLibrary("helloworld");
        }

        private native String printJNI();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.d(TAG, "Activity call JNI: " + printJNI());
    }
}

------ For reference only ----------------------------------- ----
I have encountered this problem I do not know what to solve
------ For reference only ------------------- --------------------
and android is not the main connection inside the class , I tested , I was using the 2.2 version, and then went sdk inside xxx-8 directory, copy the android.jar , renamed android.rar, and then extract the files into a folder named android , delete android.rar, go android folder, directory replication , to the classpath which together go , ok the
------ For reference only -------------------------------- -------


added which classpath? System variable or the java application in eclipse ? Are added , or not
------ For reference only -------------------------------- -------
online that are scattered, after a day of inquiries and countless failures and found something like this .

1. , such as 10 F, said : According to the android system is different in different versions generate an android folder.

2. system variable is set :
(1) My Computer - Properties - Advanced - Environment Variables
increase system variables : java_home: D: \ Program Files \ Java \ jdk1.7.0_01 (java installed after the path ) ,
Path variable, add % java_home% / bin,
increase system variables : classpath:.; D: \ Program Files \ Android \ android-sdk \ platforms \ android-8 \ android ( first 1:00 android folder path , with particular attention to add . " ; "Otherwise it will fail to )

3. in eclipse build project , of course, the best error-free . In the cmd window enter engineering classes directory run : javah-jni package name. Class name

------ For reference only ---------------------------------- -----
with the path on the implementation of

cd / bin / classes

execute javah-jni com.example.HelloWorld

thanked. . . .


------ For reference only ---------------------------------- -----


Why android-8 do ?
------ For reference only -------------------------------------- -



Why platforms \ android-8 instead of platforms \ android-7 or platforms \ android-9? Thank you advice
------ For reference only ------------------------------------ ---
ultimately did not get the solution hope that we can give a definite answer .
------ For reference only -------------------------------------- -
if built android no contact classes and a java class no separate question , how long the class will not work with android have addressed ?
------ For reference only -------------------------------------- -
because of my own projects is 2.2 . The projects are generally 2.2 or 2.3 according to their own choice going to get .
------ For reference only -------------------------------------- -
ANDROID system directly into the source code compiler environment is very simple .
------ For reference only -------------------------------------- -
javah-jni com.example.HelloWorld

com.example Yes, you package

If the path is : / home / user / com / example / HelloWorld.class

then the / home / user execute javah

Positive Solutions
------ For reference only --------------------------------- ------
D: \ workspace \ DiskNumber \ src \ com \ tjn \ test first
cd D: \ workspace \ DiskNumber \ src \ com \ tjn \ test and then run javac TestDll.java generate class files,
need to generate header files, enter
set classpath = D: \ workspace \ DiskNumber \ src , to the project's src root directory, then run
javah-jni com.tjn.test.TestDll
------ For reference only ---------------------- -----------------
21 House said setting set classpath = D: \ workspace \ DiskNumber \ src the class path settings can be very helpful , thank you.
------ For reference only -------------------------------------- -
finally found the answer. Thank you. . .

没有评论:

发表评论