Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when build Ella, "java.lang.RuntimeException: The executable 'android' is not in the path" #13

Closed
SioYooo opened this issue May 18, 2022 · 2 comments

Comments

@SioYooo
Copy link

SioYooo commented May 18, 2022

Hi there,

I have tried to built the ella for a few days, however it seems like it is not working. My error is the same as the other issue page:
(#12)

I have tried to build Ella on my Mac and also on a ubuntu server which is running 20.04.

I have installed all the requested environment.

And then I run the ant command on the ella directory, it shows this error message:

ant
Buildfile: /Users/sioyoo/tools/ella/build.xml

create-keystore:

init:

build:

init:

compile:

jar:

init:
    [javac] /Users/sioyoo/tools/ella/runtime/build.xml:15: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

BUILD FAILED
/Users/sioyoo/tools/ella/build.xml:49: The following error occurred while executing this line:
/Users/sioyoo/tools/ella/runtime/build.xml:21: java.lang.RuntimeException: The executable 'android' is not in the path
	at GuessDefaultSettingsTask.findAndroidSDKPath(GuessDefaultSettingsTask.java:46)
	at GuessDefaultSettingsTask.execute(GuessDefaultSettingsTask.java:11)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
	at org.apache.tools.ant.Main.runBuild(Main.java:818)
	at org.apache.tools.ant.Main.startAnt(Main.java:223)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Total time: 0 seconds

However I have set the path for Android.jar and also the android build tool in the ella.settings file

#Copy this file to a file named "ella.settings"
# and change that file if necessary

# set to "true" if the instrumented app will be executed on an emulator *AND*
# the ella server will be run on the host machine of the emulator.
# otherwise set to "false"
ella.use.emulator.host.loopback=true

# if ella.use.emulator.host.loopback is set to "false" *AND*
# ella server will be running on a machine that is different
# from the machine on which instrumentor is run, then set
# the following to the IP address of the machine on which
# the ella server will be run
#ella.server.ip=1.2.3.4

#port number that ella server is listening on
ella.server.port=23745

# directory where ella stores coverage data and other stuff
ella.outdir=ella-out

ella.instrumentor=com.apposcopy.ella.MethodCoverageInstrumentor
#ella.instrumentor=com.apposcopy.ella.CallArgInstrumentor,com.apposcopy.ella.MethodParamInstrumentor

# generate a trace that can be fed to traceview toold
ella.android.debug=false

# file that list names of classes that are excluded from instrumentation
ella.exclude=ella-exclude.txt

# max heap space given to JVM running the instrumentor 
ella.instrumentor.max.heapsize=2g

# max heap space given to JVM running the server
ella.server.max.heapsize=2g

# path to "build-tools" inside android SDK
# in default setting, the path is estimated
#ella.android.buildtools.dir=/opt/android-sdk-linux/build-tools/22.0.1/

# android jar to compile (ella runtime library) against
# in default setting, the path is estimated
#ella.android.jar=/opt/android-sdk-linux/platforms/android-19/android.jar

# settings used by jarsigner to sign the instrumented apk
ella.jarsigner.keystore=.android/debug.keystore
ella.jarsigner.storepass=android
ella.jarsigner.keypass=android
ella.jarsigner.alias=androiddebugkey


ella.android.buildtools.dir=~/Library/Android/sdk/build-tools/32.0.0
ella.android.jar=~/Library/Android/sdk/platforms/android-32/android.jar

In the last two lines with the path to these two files.

Could anyone please help me solve this problem?

@nicoostendorf
Copy link

nicoostendorf commented May 21, 2022

You need to edit the <path_to_ella>/ella/runtime/GuessDefaultSettingsTask.java file.
You need to set the file path hard, because the dynamic reading doesn't work for everyone..

Your new file have to look like this:

import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;

import java.util.*;
import java.io.*;

public class GuessDefaultSettingsTask extends Task
{
	public void execute() throws BuildException
	{
		String sdkPath = findAndroidSDKPath();
		String btPath = getProject().getProperty("ella.android.buildtools.dir");
		if(btPath == null){
			btPath = findAndroidBuildToolsPath(sdkPath);
			System.out.println("path to build-tools directory: "+btPath);			
		}
		File dxPath = new File(btPath, "dx");
		if(!dxPath.isFile())
			throw new Error("The configuration variable android.buildtools.dir is probably not set correctly. Current value is "+btPath);
		getProject().setProperty("ella.android.buildtools.dir", btPath);
		String androidJarPath = getProject().getProperty("ella.android.jar");
		if(androidJarPath == null){
			androidJarPath = findAndroidJarPath(sdkPath);
			if(androidJarPath == null)
				throw new Error("Could not automatically infer path to android.jar. Set ella.android.jar variable in the .settings file.");
			getProject().setProperty("ella.android.jar", androidJarPath);
		}
	}
	
	String findAndroidSDKPath() 
	{
		File sdk = new File("/Users/nicoostendorf1/Library/Android/sdk");
		return sdk.getPath();
	}

	String findAndroidBuildToolsPath(String sdkPath)
	{
		File buildToolsDir = new File("/Users/nicoostendorf1/Library/Android/sdk/build-tools/25.0.0");
		return buildToolsDir.getPath();
	}

	String findAndroidJarPath(String sdkPath)
	{
		File jarfile = new File("/Users/nicoostendorf1/Library/Android/sdk/platforms/android-25/android.jar");
		return jarfile.getPath();
	}
}

You need to set your file path!!!

@SioYooo
Copy link
Author

SioYooo commented May 23, 2022

You need to edit the <path_to_ella>/ella/runtime/GuessDefaultSettingsTask.java file. You need to set the file path hard, because the dynamic reading doesn't work for everyone..

Your new file have to look like this:

import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;

import java.util.*;
import java.io.*;

public class GuessDefaultSettingsTask extends Task
{
	public void execute() throws BuildException
	{
		String sdkPath = findAndroidSDKPath();
		String btPath = getProject().getProperty("ella.android.buildtools.dir");
		if(btPath == null){
			btPath = findAndroidBuildToolsPath(sdkPath);
			System.out.println("path to build-tools directory: "+btPath);			
		}
		File dxPath = new File(btPath, "dx");
		if(!dxPath.isFile())
			throw new Error("The configuration variable android.buildtools.dir is probably not set correctly. Current value is "+btPath);
		getProject().setProperty("ella.android.buildtools.dir", btPath);
		String androidJarPath = getProject().getProperty("ella.android.jar");
		if(androidJarPath == null){
			androidJarPath = findAndroidJarPath(sdkPath);
			if(androidJarPath == null)
				throw new Error("Could not automatically infer path to android.jar. Set ella.android.jar variable in the .settings file.");
			getProject().setProperty("ella.android.jar", androidJarPath);
		}
	}
	
	String findAndroidSDKPath() 
	{
		File sdk = new File("/Users/nicoostendorf1/Library/Android/sdk");
		return sdk.getPath();
	}

	String findAndroidBuildToolsPath(String sdkPath)
	{
		File buildToolsDir = new File("/Users/nicoostendorf1/Library/Android/sdk/build-tools/25.0.0");
		return buildToolsDir.getPath();
	}

	String findAndroidJarPath(String sdkPath)
	{
		File jarfile = new File("/Users/nicoostendorf1/Library/Android/sdk/platforms/android-25/android.jar");
		return jarfile.getPath();
	}
}

You need to set your file path!!!

Thanks a lot, it worked on my Mac.

@SioYooo SioYooo closed this as completed May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants