Lock for Android v1


This document covers an outdated version of Lock for Android. We recommend you to upgrade to v2

Check out the Lock.Android repository on GitHub.


Android API level 15+ is required in order to use Lock's UI. If you'll create your own API and just call Auth0 API via the, the minimum required API level is 9.


Lock is available both in Maven Central and JCenter. To start using Lock add these lines to your build.gradle dependencies file:

compile ''

Once it's installed, you'll need to configure LockActivity in yourAndroidManifest.xml, inside the application tag:

<!--Auth0 Lock-->
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="a0INSERT_YOUR_APP_CLIENT_ID" android:host=""/>
<meta-data android:name="com.auth0.lock.client-id" android:value="@string/auth0_client_id"/>
<meta-data android:name="com.auth0.lock.domain-url" android:value="@string/auth0_domain"/>
<!--Auth0 Lock End-->

The value @string/auth0_client_id is your application's clientID and @string/auth0_domain is your tenant's domain in Auth0, both values can be found in your app's settings.

The final value of android:scheme must be in lowercase.

Also, you'll need to add Internet permission to your application:

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

Finally, make your Application class (The one that extends from implement the interface com.auth0.lock.LockProvider and add the following code:

public class MyApplication extends Application implements LockProvider {

  private Lock lock;

  public void onCreate() {
    lock = new Lock.Builder()
      /** Other configuration goes here */

  public Lock getLock() {
    return lock;

You can check here for more configuration options

You should also add your Application class to the AndroidManifest.xml.

        <!-- Other configuration goes here -->


And include the following code in your build.gradle file.

android {
  packagingOptions {
      exclude 'META-INF/NOTICE'
      exclude 'META-INF/LICENSE'

Authentication with Lock

LockActivity will handle Email/Password, Enterprise & Social authentication based on your Application's connections enabled in your Auth0's Dashboard.

When a user authenticates successfully, LockActivity will send an Action using LocalBroadcastManager and then finish itself (by calling finish()). The activity that is interested in receiving this Action (In this case the one that will show Lock) needs to register a listener in the LocalBroadcastManager:

// This activity will show Lock
public class HomeActivity extends Activity {

  private LocalBroadcastManager broadcastManager;

  private BroadcastReceiver authenticationReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
      UserProfile profile = intent.getParcelableExtra(Lock.AUTHENTICATION_ACTION_PROFILE_PARAMETER);
      Token token = intent.getParcelableExtra(Lock.AUTHENTICATION_ACTION_TOKEN_PARAMETER);
      Log.i(TAG, "User " + profile.getName() + " logged in");

  protected void onCreate(Bundle savedInstanceState) {
    //Customize your activity

    broadcastManager = LocalBroadcastManager.getInstance(this);
    broadcastManager.registerReceiver(authenticationReceiver, new IntentFilter(Lock.AUTHENTICATION_ACTION));

  protected void onDestroy() {

Then just start LockActivity

Intent lockIntent = new Intent(this, LockActivity.class);

And you'll see our native login screen

Lock Screenshot

By default all social authentication will be done using an external browser, if you want native integration please check this wiki page.


In the proguard directory you can find the Proguard configuration for Lock and its dependencies. By default you should at least use the following files:


and if you use Facebook or Google+ native integration, you'll need and respectively.

You specify several files in you application's build.gradle like this:

buildTypes {
  release {
    minifyEnabled true
    proguardFile '../proguard/' //facebook native auth
    proguardFile '../proguard/' //G+ native auth
    proguardFile '../proguard/' //Auth0 core
    proguardFile '../proguard/' //Auth0 core
    proguardFile '../proguard/' //Lock
    proguardFile '../proguard/' //Lock
    //Add your app's specific proguard rules