Search code examples
javaandroidperformanceandroid-studiolinkedin-api

Linkedin Integration


Hello i have a integration linkedin sdk

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "my_package"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 2
        versionName "1.01"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    signingConfigs {
        sdkTest {
            storeFile file("/home/xx/Escritorio/android-studio/bin/app.jks")
            storePassword "1234567"
            keyAlias "Package Hash"
            keyPassword "1234567"
        }

        release {
             storeFile file("/home/xx/Escritorio/android-studio/bin/app.jks")
            storePassword "1234567"
            keyAlias "Package Hash"
            keyPassword "1234567"
        }
    }
}
buildscript {
    repositories {
        mavenCentral()
    }
}
allprojects {
    repositories {
        mavenCentral()
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile project(':linkedin-sdk')
}

and reviced this error

 E/LINKEDING ERROR 1﹕ {
    "errorCode": "INVALID_REQUEST",
    "errorMessage": "either bundle id or package name \/ hash are invalid, unknown, malformed"
    }

whats is a way to integrate fine a linkedin how to fix this code?

I'm not sure you can go inside file build.gradle

this working but when user acept linkedin auth im recived this error


Solution

  • This error occurs may be because the hash key you used to integrate your app with LinkedIn is wrong.

    I faced the same problem a while ago and found out that hash key generated through terminal was wrong. You can use the following method to generate hash key through your java code :

    public void generateHashkey(){
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    PACKAGE,
                    PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
    
                Log.e("Hash key", ""+Base64.encodeToString(md.digest(),Base64.NO_WRAP));
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d(TAG, e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            Log.d(TAG, e.getMessage(), e);
        }
    }
    

    You can check the following tutorial for complete process of Android Integration of LinkedIn and Login in android app