import android.view.MotionEvent?

edited July 2015 in Android Mode

I have the ketai library and wrote this: import ketai.ui.*;. Then this: import android.view.MotionEvent but the console prints me: No library found for android.view. The label above the console prints me:"The type android.view.MotionEvent cannot be resolved. It indirectly referenced from required .class files". How can I fix this? Do I have to download something? If I have to download, how can I download it?

Answers

  • @infsys== can you send your code??? - There is some problem with your import but i have to see...

  • edited July 2015

    Code from the book Rapid Android Development by Daniel Sauter that I used for learning:

        import ketai.ui.*;
        import android.view.MotionEvent;
    
        KetaiGesture gesture;
        float rectSize = 100;
        float rectAngle = 0;
        int x, y;
    
        color c = color(255);
        color bg = color(78, 93, 75);
    
        void setup() {
         orientation(LANDSCAPE);
         gesture = new KetaiGesture(this);
    
        textSize(32);
        textAlign(CENTER, BOTTOM);
        rectMode(CENTER);
        noStroke();
    
        x = width/2;
        y = height/2;
        }
    
        void draw() {
         background(bg);
        pushMatrix();
        translate(x, y);
        rotate(rectAngle);
        fill(c);
        rect(0, 0, rectSize, rectSize);
        popMatrix();
        }
    
        void onTap(float x, float y) {
          text("SINGLE", x, y-10);
          println("SINGLE:" + x + "," + y);
        }
    
        void onDoubleTap(float x, float Y) {
          text("DOUBLE", x, y-10);
          println("DOUBLE:" + x + "," + y);
          if (rectSize > 100)
            rectSize = 100;
            else
            rectSize = height - 100;
        }
    
        void onLongPress(float x, float y) {
          text("LONG", x, y - 10);
          println("LONG:" + x + "," + y);
    
          c = color(random(255), random(255), random(255));
        }
    
        void onFlick(float x, float y, float px, float py) {
          text("FLICK", X, Y-10);
          println("FLICK:" + x + "," + y + "," + v);
    
          bg = color(random(255), random(255), random(255));
        }
    
        void onPinch(float x, float y, float d) {
          rectSize = constrain(rectSize+d, 10, 500);
          println("PINCH:" + x + "," + y + "," + d);
        }
    
        void onRotate(float x, float y, float angle) {
          rectAngle += angle;
          println("ROTATE:" + angle);
        }
    
        void mouseDragged() {
          if (abs(mouseX - x) < rectSize/5 && abs(mouseY - y) < rectSize/2) {
            if (abs(mouseX - pmouseX) < rectSize/2)
              x += mouseX - pmouseX;
            if (abs(mouseY - pmouseY) < rectSize/2)
              y += mouseY - pmouseY;
          }
        }
    
        public boolean surfaceTouchEvent(MotionEvent event) {
          // Call to keep mouseX and mouseY constants updated
          super.surfaceTouchEvent(event);
          // Forward events
          return gesture.surfaceTouchEvent(event);
        }
    
  • edited July 2015

    Thanks. Paste, select, then c button. I edited the code. :D

  • edited July 2015

    On Android Mode the label says "Error from inside the Android tools, check the console." But in the console prints: java.io.FileNotFoundException: C:\Users\Carlos\Documents\Processing\modes\AndroidMode\icons\icon-96.png (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(Unknown Source) at processing.app.Base.copyFile(Base.java:2698) at processing.mode.android.AndroidBuild.writeRes(AndroidBuild.java:807) at processing.mode.android.AndroidBuild.createProject(AndroidBuild.java:169) at processing.mode.android.AndroidBuild.build(AndroidBuild.java:91) at processing.mode.android.AndroidMode.handleRunDevice(AndroidMode.java:227) at processing.mode.android.AndroidEditor$16.run(AndroidEditor.java:513) [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin [echo] C:\Users\Carlos\Desktop\Processing-2.2.1\tools/../modes/java/mode/ecj.jar [echo] org.eclipse.jdt.core.JDTCompilerAdapter

    -set-mode-check:

    -set-debug-files:

    -check-env: Android SDK Tools Revision 24.3.3 Installed at C:\Users\Carlos\AppData\Local\Android\android-sdk

    -setup: [echo] Project Name: GestureChap2 Project Type: Application

    -set-debug-mode:

    -debug-obfuscation-check:

    -pre-build:

    -build-setup: Using latest Build Tools: 22.0.1 [echo] Resolving Build Target for GestureChap2... Project Target: Android 5.0.1 API level: 21 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\res [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\rsObj [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\rsLibs [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\gen [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\classes [mkdir] Created dir: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\dexedLibs [echo] ---------- [echo] Resolving Dependencies for GestureChap2... Library dependencies: No Libraries


     [echo] ----------
     [echo] Building Libraries with 'debug'...
    

    [subant] No sub-builds to iterate on

    -code-gen: Merging AndroidManifest files into one. Manifest merger disabled. Using project manifest only. [echo] Handling aidl files... No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [echo] ---------- [echo] Handling Resources... Generating resource IDs... [echo] ---------- [echo] Handling BuildConfig class... Generating BuildConfig class.

    -pre-compile:

    -compile:

    [javac] Compiling 3 source files to C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\bin\classes

    1. ERROR in C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\src\processing\test\gesturechap2\GestureChap2.java (at line 79) println("FLICK:" + x + "," + y + "," + v); ^

    v cannot be resolved

    1 problem (1 error) BUILD FAILED C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\build.xml:15: The following error occurred while executing this line: C:\Users\Carlos\AppData\Local\Temp\android1452769842111108320sketch\build.xml:28: Compile failed; see the compiler error output for details.

    Total time: 5 seconds

  • Answer ✓

    @infsys:::

    tested the code --- not any problems with import ----your error is described in the console message::

    a) what is "X", what is "Y"; change X for x and Y to y

    b) "v" is never typed or defined; try "float v = px -py" or something like this ( i cannot guess because i know "onFling()" bt never seen onFlick(); with onFling() px && py are velocity for the gesture:: could it be that "v" is here for "velocity"???

    after that no more errors for me...

    --- it seems also that one icon is not present in your android mode folder but that is not very important for the moment, probably the laucher icon

  • Yes. X to x, Y to y and an additional parameter float v for velocity. I never thought those were the errors. I have to be careful with the syntax. I thought it was the import. There is no yellow line indicating the errors in Android Mode. Thanks. This code will be helpful for the games: for ex. I was using mouseClicked() but now I have real options for Android mode.

  • @infsys: forget on mousePresssed() & so on:: you are on a smartphone && there are a lot of gestures (more than in your code)... happy to help.

Sign In or Register to comment.