NDK: ant 错误 [javah] Exception in thread "main" java.lang.NullPointerException

版权声明:本文为博主原创文章,欢迎转载,转载请注明出处,向分享精神致敬。 https://blog.csdn.net/qilvmilv/article/details/50459231

1.错误内容

Buildfile: D:\workspacebin\eclipseWorkspace\HelloNDK\build_headers.xml
BuildHeaders:
BuildGetStringHeaders:
    [javah] Exception in thread "main" java.lang.NullPointerException
    [javah] 	at com.sun.tools.javah.JavahTask.run(JavahTask.java:503)
    [javah] 	at com.sun.tools.javah.JavahTask.run(JavahTask.java:329)
    [javah] 	at com.sun.tools.javah.Main.main(Main.java:46)

BUILD FAILED
D:\workspacebin\eclipseWorkspace\HelloNDK\build_headers.xml:19: The following error occurred while executing this line:
D:\workspacebin\eclipseWorkspace\HelloNDK\build_headers.xml:26: compilation failed

Total time: 1 second

ant脚本内容:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== 
     2016年1月4日 下午10:42:01                                                        

     HelloNDK    
     description
                                                            
     ====================================================================== -->
<project name="HelloNDK" default="BuildHeaders">
    <description>
            description
    </description>

    <!-- ================================= 
          target: buildHeaders              
         ================================= -->
    <target name="BuildHeaders" >
        <antcall target="BuildGetStringHeaders"></antcall>
    </target>

    <!-- - - - - - - - - - - - - - - - - - 
          target: BuildGetStringHeaders                      
         - - - - - - - - - - - - - - - - - -->
    <target name="BuildGetStringHeaders">
    	<javah destdir="./jni" classpath="./bin/classes/" class="com.bubble.hellondk.GetString"></javah>
    </target>

</project>

2.解决方案:

Run -> External Tools -> External Tools Configurations dialog,选择Run in Same JRE as workspace

 
After adding tools.jar to the ant runtime classpath, I also experienced (Eclipse Kepler for Windows 7 64-bit) the javah null pointer exception mentioned above. The correct fix for this subsequent problem was to specify "Run in Same JRE as workspace" on the JRE tab of each ant build file in the Run -> External Tools -> External Tools Configurations dialog. If you have multiple JREs installed, you might have to specify a specific (i.e., separate) JRE from the list of installed JREs

参考:http://stackoverflow.com/questions/15032230/cant-load-javah-error-in-eclipse



猜你喜欢

转载自blog.csdn.net/qilvmilv/article/details/50459231