0

I wanted to create an ane file using UrbanAirship latest sdk. I have added Autopilot metadata(<meta-data android:name="com.urbanairship.autopilot" android:value="com.sample.aneAndroid.TakeOffHelper" /> ) in my app-xml under the application block and also created a subclass of Autopilot and added AirshipConfigOptions there. When I try to call Autopilot.automaticTakeOff(app); in the class which implement FREFunction it gives below error-

02-03 17:14:11.949  23088-23088/? I/dalvikvm﹕ Could not find method com.urbanairship.Autopilot.automaticTakeOff, referenced from method com.sample.aneAndroid.UAPushNotificationExtensionSubscribeFunction.call
02-03 17:14:11.949  23088-23088/? W/dalvikvm﹕ VFY: unable to resolve static method 3322: Lcom/urbanairship/Autopilot;.automaticTakeOff (Landroid/app/Application;)V

TakeOffHelper.java

@Override
    public AirshipConfigOptions createAirshipConfigOptions(Context context) {
        Log.v("Autopilot", "createAirshipConfigOptions called");
        AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(context.getApplicationContext());
        Log.v("Autopilot", "createAirshipConfigOptions called " + options);
        return options;
    }

    @Override
    public void onAirshipReady(UAirship airship) {
        Log.v("Autopilot", "onAirshipReady called");
         DefaultNotificationFactory defaultNotificationFactory = new DefaultNotificationFactory(UAirship.getApplicationContext());
        defaultNotificationFactory.setColor(NotificationCompat.COLOR_DEFAULT);

        // Set it
        airship.getPushManager().setNotificationFactory(defaultNotificationFactory);

        // Enable Push
        airship.getPushManager().setPushEnabled(true);

    }

UAPushNotificationExtensionInitFunction.java

public FREObject call(FREContext context, FREObject[] args) {

        UAPushNotificationExtensionContext nec = (UAPushNotificationExtensionContext) context;
        android.app.Activity activity = nec.getActivity();
        nec.activity = activity;

         Application app = context.getActivity().getApplication();
         Autopilot.automaticTakeOff(app);}
Randhir Kumar
  • 197
  • 10

1 Answers1

0

This is probably due to an incorrect .jar file. I use a command in the following format to build my ANEs:

adt -package -target ane bin/airshipWrapper.ane src/extension.xml -swc lib/airshipWrapper.swc -platform Android-ARM -C working/android . -platform default -C working/default .

bin/airshipWrapper.ane is your target location for the ANE

src/extension.xml is the path to your extension.xml for the ANE you're trying to build

lib/airshipWrapper.swc is the path to the swc with your Actionscript classes for the ANE (this is where you put your class that calls ExtensionContext.createExtensionContext()).

working/android is your path containing your airshipWrapper.jar and library.swf

airshipWrapper.jar is a combined jar file with your Java classes and all library classes needed*

library.swf is extracted from your airshipWrapper.swc.

working/default is your path containing a library.swf with the same signature as your classes in airshipWrapper.swc (so your project doesn't break when you run it in the emulator)

*For the jar file, I export it from my Java project, then run a jar update with any necessary library classes. I use ant, but any method of extracting classes from one jar and updating another will do.

See also AIR 3 Native Extensions for Android - Can I/How to include 3rd party libraries? for more reading about the combined .jar file.

Community
  • 1
  • 1
Brian
  • 3,850
  • 3
  • 21
  • 37