蚂蚁构建错误"java.lang.RuntimeException: The executable 'android' is not in the path"



我正在尝试从https://github.com/saswatanand/ella建立一个Android应用程序检测工具Ella

当我试图使用ant构建它时,它显示了这个错误:

Buildfile: /Users/sioyoo/tools/ella/build.xml
create-keystore:
init:
build:
init:
[mkdir] Created dir: /Users/sioyoo/tools/ella/instrument/build
compile:
[javac] Compiling 67 source files to /Users/sioyoo/tools/ella/instrument/build
[javac] Note: /Users/sioyoo/tools/ella/instrument/src/com/apposcopy/ella/Instrument.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
jar:
[zip] Building zip: /Users/sioyoo/tools/ella/bin/ella.instrument.jar
init:
[mkdir] Created dir: /Users/sioyoo/tools/ella/runtime/build
[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
[javac] Compiling 1 source file to /Users/sioyoo/tools/ella/runtime
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: 1 second

然而,在设置文件中,我的android构建工具被设置为location:

/Users/sioyoo/Library/Android/sdk/build-tools/32.0.0

实际上是我保存android构建工具的地方。

有谁能帮我一下吗?我正在使用MacOS来构建这个工具。

我通过编辑/ella/runtime/GuessDefaultSettingsTask.java文件如下:

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[] sCmdExts = {""}; //TODO: support windows?
StringTokenizer st = new StringTokenizer(System.getenv("PATH"), File.pathSeparator);
String path, sFile;
while (st.hasMoreTokens()) {
path = st.nextToken();
for (String sExt : sCmdExts) {
sFile = path + File.separator + "android" + sExt;
File file = new File(sFile);
if (file.isFile()) {
return file.getAbsoluteFile().getParentFile().getParent();
}
}
}
throw new RuntimeException("The executable 'android' is not in the path");*/
}
String findAndroidBuildToolsPath(String sdkPath)
{
/*File buildToolsDir = new File(sdkPath, "build-tools");
//find the latest version
String latestVersion = null;
for(String v : buildToolsDir.list()){
if(latestVersion == null || v.compareTo(latestVersion) > 0){
latestVersion = v;
}
}
assert latestVersion != null : "Build tools not found";
//return buildToolsDir.getPath()+File.separator+latestVersion;*/
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();
/*File platformsDir = new File(sdkPath, "platforms");
String latestVersion = null;
for(File v : platformsDir.listFiles()){
if(!v.getName().startsWith("android-"))
continue;
File androidJar = new File(v, "android.jar");
if(androidJar.isFile())
return androidJar.getPath();
}
return null;*/
}
}

你必须编辑文件路径,就像你需要它!

相关内容

  • 没有找到相关文章

最新更新