Rush • A new and improved way of building extensions

You need to run rush build from the command line.

do you have a telegram?

Make sure you have JDK 8 installed and correctly set up.

I do, but I'd rather have you ask your queries here publically so others can refer to them as well.

1 Like

I already told you what you need to do:


Also, please don't spam the topic by posting multiple small replies, it's always best to write everything down in a single reply.

3 Likes

I am trying to compile my extension with Rush so that I can put ads in my app but the build failed.
Screenshot from 2022-11-02 11-40-12

I don't know where the problem is but I am going to post a picture.

The top arrow points to the line that I was instructed to add in this guide. How can I add admob extension to my app?
I do not know if the line is correct. For example, the star at the end of the line.
Furthermore, I don't know if the @UserPermissions line and the @UsesApplicationMetadata line are in the correct place.

Here's the text from this picture. (my .java file that was created when I ran
rush create <projectname>

package io.htwgadsext;

import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import com.google.appinventor.components.runtime.util.YailList;
import com.google.appinventor.components.annotations.androidmanifest.*;

public class Htwgadsext extends AndroidNonvisibleComponent {

public Htwgadsext(ComponentContainer container) {
super(container.$form());
}

@UsesPermissions(permissionNames = "")
@UsesApplicationMetadata(metaDataElements={@MetaDataElement(name="com.google.android.gms.ads.APPLICATION_ID", value="App-ID-Number")})

@SimpleFunction(description = "Returns the sum of the given list of integers.")
public int SumAll(YailList integers) {
int sum = 0;

for (final Object o : integers.toArray()) {
  try {
    sum += Integer.parseInt(o.toString());
  } catch (NumberFormatException e) {
    throw new YailRuntimeError(e.toString(), "NumberFormatException");
  }
}

return sum;

}

}

Here is the contents of the rush.yml file.

# For a detailed info on this file and supported fields, check out the below link:
# https://github.com/ShreyashSaitwal/rush-cli/wiki/Metadata-File

---
name: NameName
description: Extension component for PackageName. Created using Rush.

version:
  number: auto
  name: '1'

authors:
  - BlahBlah

build:
  release:
    # Optimizes the extension on every release build.
    optimize: true

  # If enabled, you will be able to use Java 8 language features in your extension.
  desugar:
    enable: false
    desugar_deps: false

assets:
  # Extension icon. This can be a URL or a local image in 'assets' folder.
  icon: icon.png
  # Extension assets.
  # other:
  #   - my_awesome_asset.anything

# Extension dependencies (JAR).
# deps:
#   - my_awesome_library.jar

Here is the xml file's contents.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.Package">
  <application>
    <!-- <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity> -->
  </application>
</manifest>

Thanks for any help!

Your build is failing because you don't have Java Development Kit (JDK) installed. Make sure to install version 8 (or 1.8).

Also, there are no UsesPermissions, UsesApplicationMetadata and similar annotations in Rush. You need to define required manifest tags in the AndroidManifest.xml of your extension.

Can anyone help me with this error?


Also, can anyone show me the content of the AndroidManifest.xml file so that I can just put in my app ID?

Thanks you

Refresh your browser, exit the Companion and connect again.

2 Likes

I got this Runtime Error A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Can anyone show me the content of the AndroidManifest.xml file so that I can just put in my app ID?

I built a rush extension and it seems to be causing errors when I try to use the companion so I am just going to put it together, hoping that everything is fine and that the admob stuff just simply doesn't work inside the App Inventor Companion.
Although, I have one last concern.
Do I need to integrate these blocks in some specific way to make my rush extension work? (as in, do I need to call it so that the app ID is being identified)
![Screenshot_20221104-212652|259x500]
ai-admobext

You'd usually do this in your extension's code, not in the blocks. I just quickly went through the getting started guide of AdMob Android SDK, and this is what the configure your app section's 3rd point says:

"Add your AdMob app ID (identified in the AdMob UI) to your app's AndroidManifest.xml file. To do so, add a <meta-data> tag with android:name="com.google.android.gms.ads.APPLICATION_ID". You can find your app ID in the AdMob UI. For android:value, insert your own AdMob app ID, surrounded by quotation marks.

<manifest>
  <application>
    <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
  </application>
</manifest>

In a real app, use your actual AdMob app ID, not the one listed above. If you're just looking to experiment with the SDK in a Hello World app, you can use the sample app ID shown above."

If you are not familiar with what Android manifest is, take a look at it's documentation here:

Hi sir, I am planning to move my projects to Rush for development. Does Rush support an extension that contains multiple files?

Now not possible. But @shreyash is testing Rush2, that can compile several extensions in one package. You may contact him for testing.

1 Like

No, I'm thinking if an extension that requires multiple Java files can be implemented in Rush? Or do I have to combine everything into one Java file?

The current version of Rush do not support multiple extension components in one extension, for combining multiple component manually would require you to change the .json files and also the Java classes.

As Kevinkun said Rush v2 is in testing, supports multiple components :smiley:

1 Like

Read from here

If this is what you mean...

2 Likes

yes

2 Likes

Bonjour.

Je me lance dans le développement d'application. J'utilise Eclipse comme IDE et lorsque j'ouvre le fichier .java généré par rush, Eclipse ne résout pas la déclaration suivante :
"import com.google.appinventor.components.runtime..... etc."

Dois-je installer une librairie dans éclipse ? Où la trouver ?

Merci.

Hello @Clo2, here official language is English.