Help adding SupportKit Cordova into Meteor app


#1

Hi, I am trying to add SupportKit into my Meteor project, I am using SupportKit’s Cordova plugin which you can find here , but I would like to know how can I add this part of the documentation using Meteor:

Android

Init SupportKit(natively) in the Application class, for example:

public class MainApplication extends Application {
    public void onCreate() {
        super.onCreate();
        SupportKit.init(this, "your-supportkit-app-token");
    }
}
The javascript init call will not work in Android. It must be done natively.

The problem is that I don’t have any idea where or how to add this (I’m not a good Android dev), and also I am having some trouble building the app if this class is not present. (I think that is the problem with the build)


#2

I’m not sure why the SupportKit plugin requires you to write native code to initialize it on Android, but I’m afraid this is kind of a pain.

You’ll have to modify the Android app in the generated Cordova project ( .meteor/local/cordova-build/platforms/android). Note however that files in here can in theory be regenerated at any time (most likely only on updates though). Also, there is no MainApplication class generated by default, so you’ll have to add it and configure it.


#3

Thanks for the reply, but what do you mean with add it and configure it sorry if this is very basic but I have never made any Android Application before so I don’t know if this means creating a new file for this or what exactly :s


#4

It’s not that straightforward, and documentation about this is lacking. Maybe you should open an issue about this on the SupportKit repository.

You’ll indeed have to create a new file for the MainApplication class (make sure to add the right imports or it won’t compile). Put it in the same directory MainActivity is in (src/com/<id>). To configure it, you’ll have to modify AndroidManifest.xml to add android:name="com.<id>.MainApplication" to the <application> element.


#5

Hey @martijnwalraven I have made some progress on the integration of this Cordova plugin, but now I have a strange error, the error I get is:

/Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/AndroidManifest.xml:32:5 Error:
   uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library
   /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/build/intermediates/exploded-aar/io.supportkit/core/1.1.1/AndroidManifest.xml 

So on my mobile-config I added:

App.setPreference('android-minSdkVersion', '15', 'android');

If I run:

meteor run android

it runs without an error and I can take a look at .meteor/local/cordova-build/plataforms/android/AndroidManifest.xml and I can see the version like this:

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />

but if I try to make a build with meteor build, than I get the error I showed to you at the start, and actually the whole error I get is:

=> Errors executing Cordova commands:                                              
                                              
   While building Cordova app for platform Android:
   Error: /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/cordova/build: Command failed with exit code 8 Error output:
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/AndroidManifest.xml:32:5 Error:
   uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library
   /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/build/intermediates/exploded-aar/io.supportkit/core/1.1.1/AndroidManifest.xml
   Suggestion: use tools:overrideLibrary="io.supportkit.core" to force usage
   
   FAILURE: Build failed with an exception.
   
   * What went wrong:
   Execution failed for task ':processArmv7ReleaseManifest'.
   > Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library
   /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/build/intermediates/exploded-aar/io.supportkit/core/1.1.1/AndroidManifest.xml
   Suggestion: use tools:overrideLibrary="io.supportkit.core" to force usage
   
   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
   
   /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
   throw e;
   ^
   Error code 1 for command: /Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/gradlew with args:
   cdvBuildRelease,-b,/Users/jeronimocosio/vno/vnomvp/.meteor/local/cordova-build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
   at ChildProcess.whenDone
   (/Users/jeronimocosio/.meteor/packages/meteor-tool/.1.1.9.199dldi++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
   at ChildProcess.emit (events.js:98:17)
   at maybeClose (child_process.js:766:16)
   at Socket.<anonymous> (child_process.js:979:11)
   at Socket.emit (events.js:95:17)
   at Pipe.close (net.js:466:12)

Any idea of how to fix this?