Compilation problem when i use java Classes [Win7]
Monkey Targets Forums/Android/Compilation problem when i use java Classes [Win7]
| ||
Hello to all. :) I have a rare problem: I have installed Monkey in a new computer, and i have modified config.winnt.txt, installed Android SDK, Java and apache-ant-1.8.2 as usual. When I test to compile to Android target i can do it correctly in many aplications, but i have a game that uses a Java class to control the vibration and i cannot get it compiled. It compiles and works OK in another computer with windows XP. I get this compilation Log: -compile: [javac] Compiling 3 source files to C:\Users\Fenris78\Desktop\Programacion\Monkey\Rocket\I-16\RocketCommander.build\android\bin\classes [javac] C:\Users\Fenris78\Desktop\Programacion\Monkey\Rocket\I-16\RocketCommander.build\android\src\com\monkeycoder\monkeygame\MonkeyGame.java:2514: cannot find symbol [javac] symbol : variable activity [javac] location: class com.monkeycoder.monkeygame.MonkeyGame [javac] vibrator = (Vibrator)MonkeyGame.activity.getSystemService(Context.VIBRATOR_SERVICE); [javac] ^ [javac] Note: C:\Users\Fenris78\Desktop\Programacion\Monkey\Rocket\I-16\RocketCommander.build\android\src\com\monkeycoder\monkeygame\MonkeyGame.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] 1 error BUILD FAILED C:\android-sdk-windows\tools\ant\build.xml:720: The following error occurred while executing this line: C:\android-sdk-windows\tools\ant\build.xml:734: Compile failed; see the compiler error output for details. TRANS FAILED: Android build failed. Total time: 7 seconds Done. When i quit the java vibration class, it compiles OK. The monkeyVibrate.java and monkeyVibrate.monkey Classes: monkeyVibrate.java import android.os.Vibrator; import android.content.Context; class monkeyvibrate { public static Vibrator vibrator; public static void StartVibrate(int millisec) { vibrator = (Vibrator)MonkeyGame.activity.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(millisec); } public static void StopVibrate() { vibrator.cancel(); } } monkeyVibrate.monkey 'Import the class Import "monkeyvibrate.java" Extern Function StartVibrate:Void(millisec : Int) = "monkeyvibrate.StartVibrate" Function StopVibrate:Void() = "monkeyvibrate.StopVibrate" Public This computer has Windows 7 Installed. I can't locate where is the problem. Any ideas? |
| ||
where did you get the code? I think the activity is not longer "MonkeyGame.activity." but now "BBAndroidGame._androidGame._activity." This java code is running perfect on my android smartphone: public static void startVibrate(int millisec) { try { vibrator = (Vibrator)BBAndroidGame._androidGame._activity.getSystemService(Context.VIBRATOR_SERVICE); if (vibrator!=null) vibrator.vibrate(millisec); } catch (java.lang.SecurityException e) { android.util.Log.e("[Monkey]", "SecurityException: " + android.util.Log.getStackTraceString(e)); } } public static void stopVibrate() { try { if (vibrator!=null) vibrator.cancel(); } catch (java.lang.SecurityException e) { android.util.Log.e("[Monkey]", "SecurityException: " + android.util.Log.getStackTraceString(e)); } } |
| ||
To be Honest... i don't know, we are a two people crew and that java code is not mine, i think we got it from some old documentation. I have changed the Java code as you show and it Works perfect now. :D The point is that the old code compiled OK in my old computer and worked in my smartphone too. I have encountered the problem only when i have reinstalled Monkey in a New computer. Now i Know how to code it properly. Thanks a lot Midimaster!! |
| ||
The Java code was what I did September last year lol ;o) |