[Android SDK] Using Lynx – An opensource Library from @pedrovgs

These are very quick steps to import Lynx into your Android project. For further information, visit the official GitHub site.

1.- Include gradle dependency for Lynx inside your project. In this moment it is this one:

compile 'com.github.pedrovgs:lynx:1.5’

you may search at the GitHub site if there are new versions

2.1.- Declare LynxActivity inside your manifest, next to the rest of your Activities

<activity android:name="com.github.pedrovgs.lynx.LynxActivity”/>

2.2.- Add READ_LOGS permission

<uses-permission android:name="android.permission.READ_LOGS"/>

3.- Then, you have three options to start using Lynx:

3a.- Open LynxActivity in code

private void openLynxActivity() {
    LynxConfig lynxConfig = new LynxConfig();
    lynxConfig.setMaxNumberOfTracesToShow(4000).setFilter("MyAppName");

        Intent lynxActivityIntent = LynxActivity.getIntent(this, lynxConfig);
    startActivity(lynxActivityIntent);
}

3b.- Add LynxView to your layout

<com.github.pedrovgs.lynx.LynxView
      xmlns:lynx="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      lynx:filter="MyAppName"
      lynx:text_size="12sp"/>

3c.- Declare an application-wide LynxShakeDetector and initialize it

public void initializeLynxShakeDetector(){
   LynxShakeDetector lynxShakeDetector = new LynxShakeDetector(this);
   lynxShakeDetector.init();
}

thanks to @pedrovgs for this fantastic library!!! 🙂

Advertisements

[Android SDK] The most elegant separator

According to this SO question, and the solutions given by toddles_fp, Dan Dar3, Alex Kucherenko, the simplest and most re-usable separator is this one:

styles.xml

<style name="Divider">
    <item name="android:layout_width">match_parent </item>
    <item name="android:layout_height">1dp </item>
    <item name="android:background">?android:attr/listDivider </item>
</style>

activity_main.xml

<View style="@style/Divider"/>

Thanks to the authors for their job. I just post this shortcut for using it in the future, and for other developers looking for the same! :-)

[Android SDK] My Facebook SDK code is not compiling anymore (error: cannot find symbol)

You may have a working Android App that integrates Facebook SDK. It may also be running in production (mine is). And after a few months, you try to recompile it and…

error: cannot find symbol

Referred to these (or maybe another) Facebook SDK classes.

com.facebook.Session;
com.facebook.SessionState;
com.facebook.Settings;
com.facebook.UiLifecycleHelper;
com.facebook.widget.FacebookDialog;

The reason: Your Facebook SDK version is too new.
Open your build.gradle file, and try changing

compile 'com.facebook.android:facebook-android-sdk:+’

for

compile 'com.facebook.android:facebook-android-sdk:3.+'

In the Facebook SDK official documentation, they encourage you to include a dependency to the latest version (4.0.0, or ‘+’, or similar), and your code was probably written for 3.X.

This issue gave me a headache diving into the code, and was as silly as that 😉

[Marmalade SDK] Compiling your extension for supporting iOS 64-bit

When deploying a Marmalade App to AARCH64 (iOS 64-bit support), it is also necessary to re-compile its native extensions.
Else, “ld” will ignore the whole extension and warn us about the fact.
In order to recompile the iOS extension, you are forced to use a Mac. This can be an impediment if you use Marmalade under Windows. The steps you basically need are

1.- Download and install Marmalade SDK for Mac
2.- If you are Windows user, release your license on Windows Marmalade Hub
3.- Activate your license in Mac Marmalade Hub
4.- Copy the whole extension’s folder from Windows to your mac
5.- Right-click on the extension’s .mkb for iphone (extensionName_iphone.mkb), select “Open with”. There will be two options: Mkb (default), and Mkb (7.4.3), choose the second one. Note that the numbers may change in future Marmalade versions
6.- A shell command-prompt will appear, and will attempt to compile the extension. Once completed, make sure that file
extensionName/lib/arm64/libExtName.a
is present. There should be also two folders with names finishing in _iphone_scons_aarch64 and _iphone_iphone_xcode. If that’s not the case, go to step 6b 🙂
6b.- [Optional] Open the extension Xcode project (it is located inside build_extName_iphone_iphone_xcode folder), go to Build settings, and select “Latest iOS SDK” (mine is 8.2 in this moment), and include “arm64” inside Valid architectures. This is explained in more depth in this document.
7.- Once process is complete, you can copy your extension folder back to your usual Marmalade installation (either under Windows or Mac), and recompile the whole App (including extension) to AARCH64 in iOS-fat mode. More info in the previous post 🙂

Sorry for the little mess going on here!! Hope it helps someone!!

[Marmalade SDK] Deploying to iOS 64-bit (AARCH64)

Since feb’2015, It is mandatory to have 64-bit support in your Marmalade App.
In order to deploy a 64-bit compatible .ipa, you need Marmalade SDK 7.5 or higher.

First, build your application using GCC AARCH64 Release, instead of old GCC ARM Release.

Then, when Marmalade Deploy Tool opens, select “ARM+AARCH64 GCC Release” (see screenshot below)

marmalade64bitm1

In the next step “Stage: Configuration – Platform selection”, select “iOS fat” as the platform.

marmalade64bitm2

Rest of the steps are the same. Click on “Deploy All” to run the deployment process. Note that iOS-native extensions must be also recompiled in a Mac running iOS 8 SDK or higher. Else, ld will ignore the .a files and extensions won’t be linked to your .ipa. If you also need to link your 64-bit iOS extension see this post.

[Android SDK] Parse Push: Can’t find any registered devices yet

I’ve followed the Parse Push start guide, and it doesn’t include the subscribing to Parse Push part. That’s why I was getting this message.

Code to solve it:

ParsePush.subscribeInBackground("", new SaveCallback() {
   public void done(ParseException e) {
      if (e == null) {
         Log.d(getPackageName(), "Subscribed OK!");
      } else {
         Log.e(getPackageName(), "Could not subscribe: "+e.getMessage());
      }
   }
 });

On Application start.

You should be able to send Push notifications from Parse control panel now 🙂

[Marmalade SDK] Provisioning profile “hell” when deploying to iOS 8 device

After several hours of

“A valid provisioning profile for this executable was not found”

I found a method that successfully runs my App in my iPad Air running iOS 8.1.2.

Pre-requisites:

– A valid DEVELOPMENT certificate (.cer).
– A valid DISTRIBUTION certificate (.cer).
– A valid DEVELOPMENT provisioning profile, including the DeviceID of your Test iPhone/iPad, and matching the AppID you indicate in your .mkb file
– A valid DISTRIBUTION provisioning profile, linked to the previously mentioned certificate.
– Certificates installed in your iPad using Apple Configurator (see screenshot below)
– Provisioning profiles also installed on the device (“iPhone Configuration Utility” can do that)

scr1

If you don’t have all the pre-requisites, this tutorial may be helpful for you.

Procedure:

1.- Download the DEVELOPMENT certificate from Apple Developer portal, file will be called “ios_development.cer”. IMPORTANT: Rename it to developer_identity.cer, and copy it to

C:\Marmalade\7.x\s3e\deploy\iphone\plugins\certificates

2.- Repeat step 1 with the DISTRIBUTION certificate. In this case, file name will be correct (distribution_identity.cer). Make sure these two files are present in your “certificates” folder: developer_identity.cer, distribution_identity.cer.

3.- In your App’s .mkb file, “deployments” section:

iphone-appid='myappid'
iphone-provisioning-profile='data/distributionprofile.mobileprovision'

4.- Generate the .ipa using Marmalade Deploy Tool. This .ipa will be signed with your DISTRIBUTION profile.

5.- Run “Marmalade iPhone Resigner” Tool, select your .ipa created in step 4, and select your DEVELOPMENT provisioning profile (.mobileprovision). Choose “iPhone Developer” as signing identity and click on Run. If an error is shown, read 5.1.

5.1.- The iPhone Resigner may display errors asking you to copy all the “C:\Marmalade\…\certificates” folder to:
PROJECT_ROOT\build_xyz_vc9\deployments\iphone\…\arm\certificates\
If this is the case, do it.
The files that iPhone Resigner is going to need are:
– developer_identity.key (generated with iPhone Sign Request tool when generating the certificate)
– developer_identity.cer (that’s your Apple development certificate, renamed this way)
– Apple Root CA.cer (downloaded from Apple Developer portal, also bundled in Marmalade)

6.- Deploy the recently created .ipa (signed with DISTRIBUTION, re-signed with DEVELOPMENT) to your iPhone or iPad. Make sure the device has the certificates and provisioning profiles installed.

In my case, this is the only way to make the App run on device. If I directly use DEVELOPMENT profile in step 3, it doesn’t work.

Hope it runs on yours too!!!

[Update] Collection of useful links with extra info about this aspect, thanks to Ryan from Marmalade team 🙂
iOS signing
iOS signing explained
creating a distribution store package
advanced iOS signing topics and tips
They are worth a read if you want to have deeper knowledge of the app store distribution process.

Good luck 🙂