Search code examples
android-studioandroid-ndkjavah

Terminal in Android Studio showing error - Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name:


I am new to NDK. I have worked for almost a week now trying to figure its working. I have seen a lot of tutorials online but to no avail. I always get stuck at this one step and am not able to proceed beyond it. The part where the javah utility is used. The first part of coding is the contents of MainActivity. The part which follows it is what I do in the terminal after building my project once. The error message that I get also shown here. Please tell me what I can do to rectify this. I am at my wits end!

Android Studio version - 1.3.1

package com.example.asish.ndk1;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
    public native String callNative();
}

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Asish\AndroidStudioProjects\NDK1>cd app

C:\Users\Asish\AndroidStudioProjects\NDK1\app>cd src

C:\Users\Asish\AndroidStudioProjects\NDK1\app\src>cd main

C:\Users\Asish\AndroidStudioProjects\NDK1\app\src\main>javah -d jni -classpath C:\Program Files\Android\android-sdk1\platforms\android-23\android.jar;C:\Program Files\Android\android -sdk1\extras\android\support\v7\appcompat\libs\android-support-v4.jar;C:\Program Files\Android\android-sdk1\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar; ....\build\intermediates\classes\debug\com\mytest package com.example.asish.ndk1.MainActivity

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: Files\Android\android-sdk1\platforms\android-23\android.jar;C:\Program at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:129) at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:107) at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:64) at com.sun.tools.javah.JavahTask.run(JavahTask.java:503) at com.sun.tools.javah.JavahTask.run(JavahTask.java:329) at com.sun.tools.javah.Main.main(Main.java:46)


Solution

  • I have solved the problem. I just realized that my sdk path location had a white space in it. I relocated my SDK folder to another directory that had no white space in the path location, made the changes in command and that did the trick.