Trying to compile an extension

Help me Shreyansh

• Build initialized

┌ Checking project files
│ info Checking metadata file (rush.yml)
│ info Checking AndroidManifest.xml file
└ done
┌ Compiling sources
│ info Picked 1 source file
│      Picked up _JAVA_OPTIONS: -Xmx1024M
│
│ erro src\com\hvs\AlarmManager\AlarmManager.java:7: cannot find symbol
│      import com.google.appinventor.components.annotations.DesignerComponent;
│                                                          ^
│        symbol:   class DesignerComponent
│        location: package com.google.appinventor.components.annotations
│ erro src\com\hvs\AlarmManager\AlarmManager.java:8: cannot find symbol
│      import com.google.appinventor.components.annotations.SimpleObject;
│                                                          ^
│        symbol:   class SimpleObject
│        location: package com.google.appinventor.components.annotations
│ erro src\com\hvs\AlarmManager\AlarmManager.java:18: cannot find symbol
│      @DesignerComponent(version = 1,
│       ^
│        symbol: class DesignerComponent
│ erro src\com\hvs\AlarmManager\AlarmManager.java:28: cannot find symbol
│      @UsesPermissions(permissionNames = "android.permission.SET_TIME_ZONE")
│       ^
│        symbol: class UsesPermissions
│ erro src\com\hvs\AlarmManager\AlarmManager.java:30: cannot find symbol
│      @SimpleObject(external = true)
│       ^
│        symbol: class SimpleObject
│ erro src\com\hvs\AlarmManager\AlarmManager.java:44: cannot find symbol
│          private final IAlarmManager mService;
│                        ^
│        symbol:   class IAlarmManager
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:45: cannot find symbol
│          AlarmManager(IAlarmManager service) {
│                       ^
│        symbol:   class IAlarmManager
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:50: cannot find symbol
│      public void set(int type, long triggerAtMillis, PendingIntent operation) {
│                                                      ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:60: cannot find symbol
│                  long intervalMillis, PendingIntent operation) {
│                                       ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:76: cannot find symbol
│                  long intervalMillis, PendingIntent operation) {
│                                       ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:85: cannot find symbol
│          public void cancel(PendingIntent operation) {
│                             ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager\AlarmManager.java:45: constructor AndroidNonvisibleComponent in class AndroidNonvisibleComponent cannot be applied to given types;
│          AlarmManager(IAlarmManager service) {
│                                              ^
│        required: Form
│        found:    no arguments
│        reason: actual and formal argument lists differ in length
└ failed

• Build failed [2s 78ms] [12 errors]
PS C:\Users\Dell\AppInventorSources\appinventor\components\src\com\hvs\AlarmManager\alarm-manager> ^C
PS C:\Users\Dell\AppInventorSources\appinventor\components\src\com\hvs\AlarmManager\alarm-manager> rush build
                      __
     _______  _______/ /_
    / ___/ / / / ___/ __ \
   / /  / /_/ (__  / / / /
  /_/   \__,_/____/_/ /_/

• Build initialized

┌ Checking project files
│ info Checking metadata file (rush.yml)
│ info Checking AndroidManifest.xml file
└ done
┌ Compiling sources
│ info Picked 1 source file
│      Picked up _JAVA_OPTIONS: -Xmx1024M
│
│ erro src\com\hvs\AlarmManager.java:7: cannot find symbol
│      import com.google.appinventor.components.annotations.DesignerComponent;
│                                                          ^
│        symbol:   class DesignerComponent
│        location: package com.google.appinventor.components.annotations
│ erro src\com\hvs\AlarmManager.java:8: cannot find symbol
│      import com.google.appinventor.components.annotations.SimpleObject;
│                                                          ^
│        symbol:   class SimpleObject
│        location: package com.google.appinventor.components.annotations
│ erro src\com\hvs\AlarmManager.java:18: cannot find symbol
│      @DesignerComponent(version = 1,
│       ^
│        symbol: class DesignerComponent
│ erro src\com\hvs\AlarmManager.java:28: cannot find symbol
│      @UsesPermissions(permissionNames = "android.permission.SET_TIME_ZONE")
│       ^
│        symbol: class UsesPermissions
│ erro src\com\hvs\AlarmManager.java:30: cannot find symbol
│      @SimpleObject(external = true)
│       ^
│        symbol: class SimpleObject
│ erro src\com\hvs\AlarmManager.java:44: cannot find symbol
│          private final IAlarmManager mService;
│                        ^
│        symbol:   class IAlarmManager
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:45: cannot find symbol
│          AlarmManager(IAlarmManager service) {
│                       ^
│        symbol:   class IAlarmManager
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:50: cannot find symbol
│      public void set(int type, long triggerAtMillis, PendingIntent operation) {
│                                                      ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:60: cannot find symbol
│                  long intervalMillis, PendingIntent operation) {
│                                       ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:76: cannot find symbol
│                  long intervalMillis, PendingIntent operation) {
│                                       ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:85: cannot find symbol
│          public void cancel(PendingIntent operation) {
│                             ^
│        symbol:   class PendingIntent
│        location: class AlarmManager
│ erro src\com\hvs\AlarmManager.java:45: constructor AndroidNonvisibleComponent in class AndroidNonvisibleComponent cannot be applied to given types;
│          AlarmManager(IAlarmManager service) {
│                                              ^
│        required: Form
│        found:    no arguments
│        reason: actual and formal argument lists differ in length
└ failed

Rush doesn't have those annotations like
DesignerComponent, simple object

Refer some open source projects made with rush

1 Like

It is showing me errors for this but this also contains in your sample chat extension also.

The first three annotations are not used in Rush, so just remove this part of the code from the project. Extension permissions and versions are set in the Rush.xml file.
The remaining 3 errors are missing imports for these classes.

1 Like

Only this error is remained

You need to show your code from line 12 and the part of the code where this constant is used. You are probably using functions not available in java8.

I make property of that and it got solved,

Screenshot 2024-10-03 205020

But the error is coming for this code now.
Screenshot 2024-10-03 205030

Error:

I think this is the last error.

Instead of pasting images, paste copied text.

private static final int RTC_WAKEUP = 0;
@SimpleProperty
public int RtcWakeup() {
return RTC_WAKEUP;
}
1 Like

Should i need to change it

Yes, Yes because this:

@SimpleProperty
public static final int RTC_WAKEUP = 0;

won't work.

2 Likes

Also I mentioned the error above, I think this is the last error.

What is the IAlarmManager class? I don't know such a class, what package does it come from? Did AI generate your code?

Please show more code, as you're probably not using annotations correctly.

You should stop randomly pasting the codes from somewhere and expect them to work after adding annotations.

I would suggest you learn extreme basics of Java, it really helps a lot. Otherwise it would require countless discussion to correct your code. Which is beyond the scope of this topic related to Rush.

8 Likes

I am taking help with Jewel and he is giving good help,

He fixes my some of my code
but the fixed code is giving error.

The code he suggested.

public boolean isTimeZoneSet = false;
    public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
    public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
    public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
    public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
    public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;

    public AlarmManager(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }

       public static class IAlarmManager {
        public static final int RTC_WAKEUP = 0;
        public static final int RTC = 1;
        public static final int ELAPSED_REALTIME_WAKEUP = 2;
        public static final int ELAPSED_REALTIME = 3;
        private final IAlarmManager mService;

        AlarmManager(IAlarmManager service) {
            mService = service;
        }
    }

My Full Code :


import android.content.Intent;
import android.os.RemoteException;

import javax.naming.Context;

import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;

    
  
    public final IAlarmManager mService;
    

public class AlarmManager extends AndroidNonvisibleComponent implements Component {
 
    public boolean isTimeZoneSet = false;
    public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
    public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
    public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
    public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
    public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;

    public AlarmManager(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }

       public static class IAlarmManager {
        public static final int RTC_WAKEUP = 0;
        public static final int RTC = 1;
        public static final int ELAPSED_REALTIME_WAKEUP = 2;
        public static final int ELAPSED_REALTIME = 3;
        private final IAlarmManager mService;

        AlarmManager(IAlarmManager service) {
            mService = service;
        }
    }


@SimpleFunction(description="Schedule an alarm.")
public void set(int type, long triggerAtMillis, PendingIntent id) {
    try {
        mService.set(type, triggerAtMillis, id);
    } catch (RemoteException ex) {
    }
}


@SimpleFunction(description="Schedule a repeating alarm.")
public void setRepeating(int type, long triggerAtMillis,
            long intervalMillis, PendingIntent id) {
        try {
            mService.setRepeating(type, triggerAtMillis, intervalMillis, id);
        } catch (RemoteException ex) {
        }
    }

    public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
    public static final long INTERVAL_HALF_HOUR = 2*INTERVAL_FIFTEEN_MINUTES;
    public static final long INTERVAL_HOUR = 2*INTERVAL_HALF_HOUR;
    public static final long INTERVAL_HALF_DAY = 12*INTERVAL_HOUR;
    public static final long INTERVAL_DAY = 2*INTERVAL_HALF_DAY;


    @SimpleFunction(description="Available inexact recurrence intervals.")
    public void setInexactRepeating(int type, long triggerAtMillis,
            long intervalMillis, PendingIntent id) {
        try {
            mService.setInexactRepeating(type, triggerAtMillis, intervalMillis, id);
        } catch (RemoteException ex) {
        }
    }


    @SimpleFunction(description="Remove any alarms with a matching")
    public void cancel(PendingIntent id) {
            try {
                mService.remove(id);
                onAlarmCancelled(id);
            } catch (RemoteException ex) {
            }
        }

        @SimpleFunction(description="Set the system wall clock time.")
        public void setTime(long millis) {
            try {
                mService.setTime(millis);
            } catch (RemoteException ex) {
            }
        }
             
        @SimpleEvent(description="Returns isTimeZoneSet")

        public void AfterTimeZoneSet(boolean isTimeZoneSet){
            EventDispatcher.dispatchEvent(this, "AfterTimeZoneSet", isTimeZoneSet); 
        }


        @SimpleEvent(description="onCancelled Alarm")
        public void onAlarmCancelled(string id){
            EventDispatcher.dispatchEvent(this, "onAlarmCancelled", id); 
        }

        @SimpleFunction(description="Set the system default time zone.")
        public void setTimeZone(String timeZone) {
            try {
                mService.setTimeZone(timeZone);
                isTimeZoneSet = true;
                AfterTimeZoneSet(isTimeZoneSet);
            } catch (RemoteException ex) {
            }
        }

         @SimpleProperty(description="RTC_WAKEUP")
        private static final int RTC_WAKEUP = 0;
         public int TYPE_RTC_WAKEUP() {
        return RTC_WAKEUP;
        }

         @SimpleProperty(description="RTC")
        public static final int RTC = 1;
        public int TYPE_RTC() {
        return RTC;
        }

        @SimpleProperty(description="ELAPSED_REALTIME_WAKEUP")
         public static final int ELAPSED_REALTIME_WAKEUP = 2;
         public int TYPE_ELAPSED_REALTIME_WAKEUP() {
            return ELAPSED_REALTIME_WAKEUP;
            }

         @SimpleProperty(description="ELAPSED_REALTIME")
         public static final int ELAPSED_REALTIME = 3;
         public int TYPE_ELAPSED_REALTIME() {
            return ELAPSED_REALTIME;
            }
}
import android.content.Intent;
import android.os.RemoteException;

import javax.naming.Context;

import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;

    
  
    public final IAlarmManager mService;
    

public class AlarmManager extends AndroidNonvisibleComponent implements Component {
 
    public boolean isTimeZoneSet = false;
    public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
    public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
    public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
    public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
    public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;

    public AlarmManager(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }

       public static class IAlarmManager {
        public static final int RTC_WAKEUP = 0;
        public static final int RTC = 1;
        public static final int ELAPSED_REALTIME_WAKEUP = 2;
        public static final int ELAPSED_REALTIME = 3;
        private final IAlarmManager mService;

        AlarmManager(IAlarmManager service) {
            mService = service;
        }
    }


@SimpleFunction(description="Schedule an alarm.")
public void set(int type, long triggerAtMillis, PendingIntent id) {
    try {
        mService.set(type, triggerAtMillis, id);
    } catch (RemoteException ex) {
    }
}


@SimpleFunction(description="Schedule a repeating alarm.")
public void setRepeating(int type, long triggerAtMillis,
            long intervalMillis, PendingIntent id) {
        try {
            mService.setRepeating(type, triggerAtMillis, intervalMillis, id);
        } catch (RemoteException ex) {
        }
    }

    public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
    public static final long INTERVAL_HALF_HOUR = 2*INTERVAL_FIFTEEN_MINUTES;
    public static final long INTERVAL_HOUR = 2*INTERVAL_HALF_HOUR;
    public static final long INTERVAL_HALF_DAY = 12*INTERVAL_HOUR;
    public static final long INTERVAL_DAY = 2*INTERVAL_HALF_DAY;


    @SimpleFunction(description="Available inexact recurrence intervals.")
    public void setInexactRepeating(int type, long triggerAtMillis,
            long intervalMillis, PendingIntent id) {
        try {
            mService.setInexactRepeating(type, triggerAtMillis, intervalMillis, id);
        } catch (RemoteException ex) {
        }
    }


    @SimpleFunction(description="Remove any alarms with a matching")
    public void cancel(PendingIntent id) {
            try {
                mService.remove(id);
                onAlarmCancelled(id);
            } catch (RemoteException ex) {
            }
        }

        @SimpleFunction(description="Set the system wall clock time.")
        public void setTime(long millis) {
            try {
                mService.setTime(millis);
            } catch (RemoteException ex) {
            }
        }
             
        @SimpleEvent(description="Returns isTimeZoneSet")

        public void AfterTimeZoneSet(boolean isTimeZoneSet){
            EventDispatcher.dispatchEvent(this, "AfterTimeZoneSet", isTimeZoneSet); 
        }


        @SimpleEvent(description="onCancelled Alarm")
        public void onAlarmCancelled(string id){
            EventDispatcher.dispatchEvent(this, "onAlarmCancelled", id); 
        }

        @SimpleFunction(description="Set the system default time zone.")
        public void setTimeZone(String timeZone) {
            try {
                mService.setTimeZone(timeZone);
                isTimeZoneSet = true;
                AfterTimeZoneSet(isTimeZoneSet);
            } catch (RemoteException ex) {
            }
        }

         @SimpleProperty(description="RTC_WAKEUP")
        private static final int RTC_WAKEUP = 0;
         public int TYPE_RTC_WAKEUP() {
        return RTC_WAKEUP;
        }

         @SimpleProperty(description="RTC")
        public static final int RTC = 1;
        public int TYPE_RTC() {
        return RTC;
        }

        @SimpleProperty(description="ELAPSED_REALTIME_WAKEUP")
         public static final int ELAPSED_REALTIME_WAKEUP = 2;
         public int TYPE_ELAPSED_REALTIME_WAKEUP() {
            return ELAPSED_REALTIME_WAKEUP;
            }

         @SimpleProperty(description="ELAPSED_REALTIME")
         public static final int ELAPSED_REALTIME = 3;
         public int TYPE_ELAPSED_REALTIME() {
            return ELAPSED_REALTIME;
            }
}

Why recreate something that has already been created? The source code is even provided. Start learning how to write extensions with something simple.

1 Like

This one is different

Please also follow the naming conventions

And in case you need inspiration of some features to add, let me suggest to take a look at App Inventor Extensions: Alarm Manager | Pura Vida Apps

Taifun

Your full code is repeated, it is duplicated.

1 Like

How can install andriod lib in VS Code? already searched alot.