Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

exec returned: 2

$
0
0

Hello,

I am new to titanium but I have written native android apps before. I am attempting to compile a module for some native android code that I wrote and I am stuck on this vague error that says "exec returned: 2".

I can only gather from the information below that either my NDK version is incompatible or Ant is misconfigured. I did notice that the titanium mobilesdk has win32 in the path and I am using 64bit Windows 7, is this a problem?

In either case, if I am correct, I am unsure how to fix it. Which NDK should I use or How should Ant be configured(as of now it is all defaults, I have not touched it, this is how I am accustomed to operating in native land).

A little about what I am trying to accomplish with this module:

I want to be able to recieve events in JS that indicate that a new Activity has been opened. The only way that I have found that works currently is to use the ActivityManager for Android. I do want this to be cross platform eventually but I could not find an exposed API from Titanium that exposes direct ActivityManager functionality or even getSystemServer for that matter. If there is an easier way I am all ears. Because I also need a cross platform speech recognition module. I have used pocketsphinx on android before but I have a feeling that there will be another learning curve to port it to IOS too.

More steps I have taken:

I have tried replacing 'failonerror="true"' with 'failonerror="false"', on build.xml:281, to see what happens(at the time it didn't seem like the build process should be using NDK but now I see that it does). When I do this the compilation finishes but when I require the module in my final Alloy app I do not see my exposed constant. I assume that the NDK portion still failed and it just continued because when I look at the .mk files and .json bindings the constant should have exported. I just don't know exactly why the NDK build failed with a 2. But another strange thing about the module that I brut forced is that windowmonitor.exampleProp is exposed but that member is not in my native source files.

Manifest from timodule.xml:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-permission android:name="android.permission.GET_TASKS"></uses-permission>
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
            <service android:name="Detector"></service>
            <receiver android:name="StartupServiceReceiver">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED"/>
                    <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
                    <action android:name="android.intent.action.USER_PRESENT"/>
                </intent-filter>
            </receiver>
        </manifest>
    </android>
KrollModule Code:
@Kroll.module(name="Windowmonitor", id="org.perpetuallight.windowmonitor")
public class WindowmonitorModule extends KrollModule
{
 
    // Standard Debugging variables
    private static final String TAG = "WindowmonitorModule";
    private static WindowmonitorModule instance;
 
    @Kroll.constant
    public final static String EVENT_NEW_WINDOW_DETECTED = "EVENT_NEW_WINDOW_DETECTED";
 
    // You can define constants with @Kroll.constant, for example:
    // @Kroll.constant public static final String EXTERNAL_NAME = value;
 
    public WindowmonitorModule()
    {
        super();
        WindowmonitorModule.instance = this;
    }
 
    @Kroll.onAppCreate
    public static void onAppCreate(TiApplication app)
    {
        Log.d(TAG, "inside onAppCreate");
        WindowmonitorModule.instance.startService();
    }
 
    // Methods
    public void startService() {
        Intent intent = new Intent(TiApplication.getAppRootOrCurrentActivity(), Detector.class);
        TiApplication.getInstance().startService(intent);
    }
 
    public static WindowmonitorModule getInstance(){
        return instance;
    }
 
}
Relevant Native Thread Loop:
@Override
        public void run() {
            String lastRun = "";
            while(!this.isInterrupted() ){
                try {
                    Thread.sleep(100);
                    ActivityManager am = (ActivityManager) getBaseContext().getSystemService(ACTIVITY_SERVICE);
                    RunningTaskInfo foregroundTaskInfo = am.getRunningTasks(1).get(0);
                    String foregroundTaskPackageName = foregroundTaskInfo.topActivity.getPackageName();
                    PackageManager pm = getBaseContext().getPackageManager();
                    PackageInfo foregroundAppPackageInfo = null;
                    String foregroundTaskActivityName = foregroundTaskInfo.topActivity.getShortClassName().toString();
                    try {
                        foregroundAppPackageInfo = pm.getPackageInfo(foregroundTaskPackageName, 0);
                    } catch (NameNotFoundException e) {
                        e.printStackTrace();
                    }
 
                    String packName = foregroundAppPackageInfo.packageName;
                    Boolean isNew = !packName.equals(lastRun);
                    if (this.entry!=null && isNew){
                        this.entry.fireEvent(
                            WindowmonitorModule.EVENT_NEW_WINDOW_DETECTED,
                            "{\"packageName\"  : \"" + packName + "\"," +
                            " \"activityName\" : \"" + foregroundTaskActivityName + "\"}"
                        );
                    }
                    lastRun = packName;
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    return;
                }
            }
        }
From project/module build.xml:
<project name="windowmonitor" default="dist">
    <description>
        Ant build script for Titanium Android module windowmonitor
    </description>
    **<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>** Added to resolve JDK location
    <property name="ti.module.root" location="${basedir}"/>
    <property file="build.properties" />
 
    <import file="${titanium.platform}/../module/android/build.xml"/>
</project>
From build.properties:
titanium.platform=C:\\Users\\Me\\AppData\\Roaming\\Titanium\\mobilesdk\\win32\\3.1.3.GA\\android
android.platform=C:\\Users\\Me\\Documents\\android-sdk-windows\\platforms\\android-10
google.apis=C:\\Users\\Me\\Documents\\android-sdk-windows\\add-ons\\addon-google_apis-google-10
**android.ndk=C:\\Users\\Me\\Documents\\android-ndk-r9b** Added to ensure NDK is reachable
Console Output:
Executing build.xml...
C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line:
C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2
From build.xml:326
<build.ndk gendir="${gen}"/>
From build.xml:281:
<exec executable="${ndk.build}" dir="${tmpdir}" failonerror="true">
                <arg value="TI_MOBILE_SDK=${mobilesdk.dir}"/>
                <arg value="NDK_PROJECT_PATH=${tmpdir}"/>
                <arg value="NDK_APPLICATION_MK=${tmpdir}/Application.mk"/>
                <arg value="PYTHON=${python.exec}"/>
                <arg value="V=${ndk.verbose}"/>
            </exec>

Stack trace from Titanium Studio Log:

!ENTRY com.appcelerator.titanium.mobile 4 0 2013-12-04 15:11:40.770 !MESSAGE (Build 3.1.3.201309132423) [ERROR] C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 !STACK 1 org.eclipse.core.runtime.CoreException: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 at org.eclipse.ant.core.AntRunner.handleInvocationTargetException(AntRunner.java:452) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:384) at com.appcelerator.titanium.mobile.ui.module.launch.AndroidModulePackageLaunchConfigurationDelegate$PackagingProcess$1.run(AndroidModulePackageLaunchConfigurationDelegate.java:223) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:551) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:401) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:665) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:498) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378) ... 2 more Caused by: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:646) at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672) at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398) ... 22 more

!SUBENTRY 1 org.eclipse.ant.core 4 1 2013-12-04 15:11:40.771 !MESSAGE C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 !STACK 0 C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:551) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:401) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:665) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:498) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378) at com.appcelerator.titanium.mobile.ui.module.launch.AndroidModulePackageLaunchConfigurationDelegate$PackagingProcess$1.run(AndroidModulePackageLaunchConfigurationDelegate.java:223) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: C:\Users\Me\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\module\android\build.xml:281: exec returned: 2 at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:646) at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672) at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398) ... 22 more


Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>