Rush • A new and improved way of building extensions

I get this occasionally as well.

Just keep running rush build until you get a compile without the warn.

What ever you do, do not load the extension built with warn to a project, it will likely irretrievably break the project!!! (Another good reason to make aia backups regularly)

2 Likes

good thing I used another project

Can Rush support mix(Java and Kotlin) directly, or are there specific configurations needed?

Yes, you can use both Kotlin and Java in your extension project, just enable Kotlin in .yml file, see docs.

Title: How to Resolve Rush Environment Variable and Path Issues on macOS

Hello Community,

I recently encountered a couple of issues while setting up the Rush CLI on macOS, and I wanted to share the solutions that worked for me. These might be helpful if you're experiencing similar problems.

Issue 1: Java Version Error

Problem:
While using Rush, I received errors related to the Java version, indicating that the wrong version of Java was being used.

Solution:
The issue was resolved by explicitly setting the JAVA_HOME environment variable to point to the correct version of Java. Here's how you can do it:

  1. Open Terminal and type:

    /usr/libexec/java_home -V
    

    This lists all installed JDKs. Choose the correct path for JDK 8.

  2. Open your shell configuration file (.zshrc for Zsh or .bash_profile for Bash) using a text editor like nano:

    nano ~/.zshrc
    
  3. Add the following line to set JAVA_HOME (replace <path_to_jdk> with your actual JDK path):

    export JAVA_HOME=<path_to_jdk>
    export PATH=$JAVA_HOME/bin:$PATH
    
  4. Save and exit the editor (Ctrl+O, Enter, Ctrl+X), then apply the changes:

    source ~/.zshrc
    
  5. Verify the setup by typing:

    java -version
    

Issue 2: Rush Data Directory Path Issue

Problem:
Rush was failing due to spaces in the path of the Rush data directory. This is a known bug that will be fixed in a future release.

Default Location:
By default, the Rush data directory is located at /Users/<yourprofile>/Library/Application Support/rush. Note that this path includes hidden directories.

Accessing Hidden Folders:
Since macOS hides certain system folders by default, you might not see the Library folder in Finder. Here's how you can access it:

  1. Open Finder:

    • Click on the Finder icon in your dock to open a new Finder window.
  2. Go to Your Home Directory:

    • Use the Go menu in the Finder menu bar and select Home, or press Command + Shift + H.
  3. Show Hidden Files:

    • While in your home directory, press Command + Shift + . (period). This will toggle the visibility of hidden files and folders. You should now see the Library folder.
  4. Navigate to the Rush Data Directory:

    • Open the Library folder, then Application Support, and finally, the rush folder. This is where Rush stores its data by default.

Solution:
I moved the Rush data directory to a path without spaces and set an environment variable to reference it. Here's the step-by-step guide:

  1. Move the Rush directory to a new location without spaces, e.g., /Users/example/rush.

  2. Open your shell configuration file:

    nano ~/.zshrc
    
  3. Add a new environment variable, RUSH_DATA_DIR:

    export RUSH_DATA_DIR="/Users/example/rush"
    
  4. Save, exit, and source your profile:

    source ~/.zshrc
    
  5. Confirm the environment variable is set:

    echo $RUSH_DATA_DIR
    

These solutions helped stabilize my setup and might help you if you're facing similar issues. Feel free to share this post or refer back to it for troubleshooting!

1 Like

Can we use Kotlin coroutines in rush? I have imported the library but getting errors.
cannot access

kotlinx.coroutines.CoroutineScope

which is a supertype of

example.com.Client


. Check your module classpath for missing or conflicting dependencies
Screenshot 2024-04-22 at 11.16.42 AM

What errors do you get?

Thanks for the reply @shreyash . Was missing a dependency and now it's fixed. Manually keeping check of all dependencies is just :exploding_head:

1 Like

I am currently developing an extension using Rush and encountering a runtime error related to the Gson library. The error leads to an app crash with the following log output:

FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: edu.mit.appinventor.aicompanion3, PID: 2616
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/ToNumberPolicy;
at com.createsuser.createuser.repack.t.(Unknown Source:5)
at com.createsuser.createuser.repack.t.a(Unknown Source:0)
at com.createsuser.createuser.repack.c.a(Unknown Source:653)
at com.createsuser.createuser.repack.aB.b(Unknown Source:16)
at com.createsuser.createuser.repack.do.run(Unknown Source:142)
at com.createsuser.createuser.repack.eA.run(Unknown Source:3)
at com.createsuser.createuser.repack.fo.run(Unknown Source:2)
at com.createsuser.createuser.repack.fc.a(Unknown Source:0)
at com.createsuser.createuser.repack.ff.run(Unknown Source:82)
Caused by: java.lang.ClassNotFoundException: com.google.gson.ToNumberPolicy

Has anyone faced a similar issue with Gson. Rush has builtin gson library. Advice or help will be much much appreciated. Thanks

Have you included your library in rush.yml

Yes, have also tried that. But it gave build error referring to Proguard. Below is the snippet.

Processing the extension
│ info Linking extension assets and dependencies
│ info Optimizing the extension
│ note there were 3179 duplicate class definitions.
│ (ProGuard Manual: Troubleshooting | Guardsquare)
│ Unexpected error while evaluating instruction:
Method = [fromJson$0(Lcom/google/gson/Gson;Lcom/google/gson/stream/JsonReader;Lproguard/optimize/gson/_OptimizedJsonReader;)V]
│ Exception = [java.lang.IllegalArgumentException] (Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue])

│ erro java.lang.IllegalArgumentException: Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue]
└ failed

Either upgrade/downgrade library or find its source code.

Hello @vknow360 and community, here are the steps I've taken and where I'm currently facing issues:

  1. Initial Approach:

    • Used the built-in Gson library provided by Rush (didn't manually include Gson in the extension folder or the YAML configuration).
    • Result: Encountered a runtime error indicating NoClassDefFoundError for com.google.gson.ToNumberPolicy.
  2. Including Gson Library Manually:

    • After facing the above error, I included the latest version of the Gson library directly in my extension folder and updated the YAML file accordingly.
    • Faced ProGuard conflicts initially, adjusted the ProGuard rules to resolve these conflicts.
    • Result: Despite resolving ProGuard conflicts, the same runtime error (NoClassDefFoundError for com.google.gson.ToNumberPolicy) persists.
  3. Additional Steps:

    • Removed the Rush-provided Gson library to avoid potential conflicts.
    • Explicitly used a newer version of Gson by including it in the extension folder and YAML file.
    • Reconfigured ProGuard with the following rule to ensure Gson classes are not stripped:
      -keep class com.google.gson.** { *; }
      

Current Issue:
Despite these adjustments, the application crashes during runtime with a NoClassDefFoundError specifically pointing to com.google.gson.ToNumberPolicy. This occurs even after explicitly ensuring Gson is not stripped or obfuscated by ProGuard.

┌ Compiling sources
│ info Picked 1 source file
│ An annotation processor threw an uncaught exception.
│ Consult the following stack trace for details.
│ java.lang.IllegalStateException
│ at io.shreyash.rush.util.ConvertToYailTypeKt.convert(ConvertToYailType.kt:142)
│ at io.shreyash.rush.block.BlockWithParams.params(BlockWithParams.kt:16)
│ at io.shreyash.rush.block.Method.runChecks(Method.kt:31)
│ at io.shreyash.rush.block.Method.(Method.kt:16)
│ at io.shreyash.rush.ExtensionProcessor.process(ExtensionProcessor.kt:68)
│ at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
│ at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
│ at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
│ at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
│ at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
│ at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
│ at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
│ at com.sun.tools.javac.main.Main.compile(Main.java:523)
│ at com.sun.tools.javac.main.Main.compile(Main.java:381)
│ at com.sun.tools.javac.main.Main.compile(Main.java:370)
│ at com.sun.tools.javac.main.Main.compile(Main.java:361)
│ at com.sun.tools.javac.Main.compile(Main.java:56)
│ at com.sun.tools.javac.Main.main(Main.java:42)
└ failed

how to solve the error?

can i install in termux?

I do not believe that this is possible.

I had heard of few people trying it in termux, you can too, you would first need to install some heavy dependencies like the JDK 8 (which isnt supposed to run on devices) and others.

But you would have no practical advantage using Rush on Android, editing the source files on termux...

It will remove compile time conflicts only. AI2 bundles gson library and that's why you see runtime error.
Better enable proguard for gson lib.

Thanks for your reply @vknow360 . Upon reviewing the MIT App Inventor sources, I noticed that the included Gson library version is 2.1, which is significantly older than the current latest version, 2.10.1.

During my investigation, I discovered that the class com.google.gson.ToNumberPolicy, which is causing a NoClassDefFoundError in my project, was introduced in Gson version 2.8.9. This class is not present in the older version (2.1) used by MIT App Inventor, leading to the aforementioned runtime error.

Could anyone suggest how to resolve this issue?Thanks again

How do I Update to the Latest Google Gson Version for Extension Development with Rush?

Hello MIT App Inventor Community,
I'm currently developing an extension and need to utilize the latest features available in Gson, specifically those introduced in version 2.8.9 and above. However, I've encountered issues due to the older version of Gson (2.1) that is integrated by default with Rush also in MIT App inventor sources.

Could anyone provide guidance or best practices on how to successfully update or configure my Rush project to use the latest Gson version (2.10.1)? I am particularly interested in:

  1. Steps to include the newer Gson library in a Rush-based extension project.
  2. Potential configuration settings or changes required in Rush to avoid conflicts with the pre-existing older Gson version.
    Your suggestions would be greatly appreciated.
    Thank you for your support!