I am working to implement LinkedIn SDK into my application. I import the demo code and created the sample project on LinkedIn developer console. I also added required package name and hash. I got those two from the sample demo code.
But after adding this two when I try to run the application it always fire the below error.
{
"errorMessage":"either bundle id or packagename / hash are invalid,unknown, malformed"
"errorCode":"INVALID_REQUEST"
}
I cross checked several time for the hash and package name because this two are parameter we have to add into console.
Posible duplicate of this post. Problem is about your are not signing correctly the APK generated. Check your signingConfig in the build.gradle file.
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
signingConfigs {
sdkTest {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
sdkTest {
signingConfig signingConfigs.sdkTest
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile project(':linkedin-sdk')
}
configurations {
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
}
Related
I'm developing unit test using JUnit 4 on Android studio, but I need to sign the library before running tests to each function of the library to be accepted on my device. I'm trying the following:
build.gradle
android {
signingConfigs {
config {
keyAlias 'xxxxx'
keyPassword 'xxxxx'
storePassword 'xxxxxx'
storeFile file('cert/platform.jks')
}
}
compileSdkVersion 26
buildToolsVersion '26.0.2'
testBuildType "debug"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.111"
externalNativeBuild {
cmake {
cppFlags "-fexceptions"
}
}
signingConfig signingConfigs.config
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
flavorDimensions "api"
productFlavors {
minApi17 {
dimension "api"
ndk.with {
moduleName = 'FAL'
abiFilters = ["armeabi"]
}
signingConfig signingConfigs.config
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
}
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/zxing-2.3.0.jar')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
I'm using this portion of code, but the application don't work in device (Certification error). What is the proper way to sign the application before running the test?
Click on Build -> Generate Signed APK -> Create new... -> add password, some credentials needed and click Next -> choose build type and flavors, check Signature Versions (check here: https://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2) but tl;dr -> choose V2.
This way you will generate dummy certificate which will sign your builds. Your gradle file will update automatically. If not than add:
signingConfigs {
config {
keyAlias 'KEY'
keyPassword 'PASSWORD'
storeFile file('../cert/fileName.jks')
storePassword 'STORE_PASSWORD'
}
to your gradle file.
It's good practice to store generated cert inside your project repo.
I now just use AndroidStudio,here is my problem:
I have a android library but there are many different environment,eg debug,test,and release,each of these environments relate a different request url,and i use maven to manage my library,each of environment relate a different maven url,i want use productFlavors to appoint different request url then build different aars and upload to maven,but i donot know how to select the specific buildType or productFlavors when uploadArchives,if there are any other ways to solve my problem,please help me,thanks!
Here is build.gradle:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
flavors_release {
resValue("string", "url", "http://....")
}
flavors_dev {
resValue("string", "url", "http://...")
}
}
uploadArchives {
repositories.mavenDeployer {
repository(url: 'http://127.0.0.1:8081/nexus/content/repositories/test/') {
authentication(userName: "admin",
password: "admin123")
}
pom.project {
name 'mylibrary'
packaging 'aar'
description ''
url 'http://127.0.0.1:8081/nexus/content/repositories/test/'
groupId ""
artifactId ''
version ""
}
}
I have solve my problem,i defined a buildConfigField:boolean TEST in defaultConfig,so in my java code,i can select the request url by judge TEST,and i can also select the local repositories address by judge TEST.Of cause,these values can be defined in the local.properties as the form of key=value!
I have Tried different type of builds using product flavors in android studio.
Ref Code:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.test.testandroid" //your app id
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("/keystore/debug.keystore")
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
googlePlayRelease {
storeFile file("/keystore/key.jks")
keyAlias 'android'
keyPassword 'android'
storePassword 'android'
}
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
debuggable true
}
}
productFlavors {
stagingBuild {
buildConfigField "boolean", "IS_DEMO", "false"
}
demoBuild {
buildConfigField "boolean", "IS_DEMO", "true"
versionCode 1
versionName "1.0"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
You can select build type in Build variant to build the apk file.
Android Studio refuses to sign my code for debug build.
I have an older project which did not have any signing instructions in build.gradle, so I added these according to this Android gradle signingConfig error and other posts.
My build.gradle file on module level (the only module) looks like this (excerpt):
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "cc.appname.android"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
signingConfigs {
debug {
storeFile file('../../../.android/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
The storeFile can be found, because when I change the path I get a compile error. When the path is correct, it compiles, but when I try to use the Facebook SDK within my app, it reports a wrong keyhash.
I noticed that signingConfigs
signingConfig signingConfigs.debug
is underlined with the error message "Cannot infer argument types..."
So I went to Project Settings in the UI, removed signing and the relationship between the build and signing, saved this, and added it back. Same problem.
I am sure this is something very small that I just overlooked, or Google renamed the command between versions, whatever.
Can anybody help?
Several things here, assuming your debug.keystore is the one from the ~/.android folder.
Change this:
debug {
storeFile file('../../../.android/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
to this(store the debug.keystore in the root project):
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
You do not need to override the debug BuildType, it naturally signs with the debug key anyways, so you can remove:
debug {
signingConfig signingConfigs.debug
}
The final build.gradle:
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "cc.appname.android"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Both buildTypes.debug and signingConfigs.debug exist by default.
You do not need to define buildTypes.debug unless you want to change it.
You do not need to define signingConfigs.debug unless you want to change it.
If you want to use the default debug signing for a different build type, you can do that. For example, the following works also without defining anything else:
buildTypes {
unsignedRelease {
initWith release
signingConfig signingConfigs.debug
}
}
Adding an answer for the new gradle experimental plugin since the syntax is different:
model {
android {
buildTypes {
release {
signingConfig = $("android.signingConfigs.myConfig")
...
}
}
}
android.signingConfigs {
create("myConfig") {
keyAlias = 'androiddebugkey'
keyPassword = 'android'
storeFile = new File("${System.properties['user.home']}/.android/debug.keystore")
storePassword = 'android'
storeType = "jks"
}
}
}
NOTE: the android.signingConfigs block must be placed outside of the android block.
I am having trouble getting a signed zipaligned gradle file built in my Android app. I am using intellij 13.1.4. The error I am receiving is Error:(34, 0) Could not find property 'configstd' on BuildTypeDsl_Decorated{name=release, debuggable=false, jniDebugBuild=false, renderscriptDebugBuild=false, renderscriptOptimLevel=3, packageNameSuffix=null, versionNameSuffix=null, runProguard=false, zipAlign=true, signingConfig=null}.
Here is my build.gradle:
` buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
signingConfigs {
configstd {
keyAlias 'myalias'
keyPassword 'mykeypassword'
storeFile file('mykeyfile.jks')
storePassword 'mystorepassword'
}
}
buildTypes {
release {
debuggable false
zipAlign true
signingConfig configstd
}
debug {
debuggable true
zipAlign false
signingConfig configstd
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
}
`
Here is what I discovered to be the problem. I originally had used the intellij's Project Structure->Facets->Android-Gradle to enter the parameters for the build.gradle file. Apparently, when it created the code to insert into the file it left off "signingConfigs" from the name of the object configstd. So in other words the line should read as follows:
signingConfig signingConfigs.configstd
I try signing my Application like this link.
I write my signingConfigs settings but I get "Could not find property" error.
This my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "Andy Warhol"
}
buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
signingConfig signingConfigs.myconfig
}
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
}
}
signingConfigs {
myconfig {
keyAlias 'xxx'
keyPassword 'xxx'
storeFile file('xxx')
storePassword 'xxx'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/picasso-2.2.0.jar')
compile files('libs/acra-4.5.0.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
}
This is my error
Gradle 'BulentTirasMobileApp' project refresh failed:
Could not find property 'myconfig' on SigningConfig container.
Move your signingConfigs block to appear before your buildTypes block:
signingConfigs {
myconfig {
keyAlias 'xxx'
keyPassword 'xxx'
storeFile file('xxx')
storePassword 'xxx'
}
}
buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
signingConfig signingConfigs.myconfig
}
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
}
}
You need to define the configuration before you can use it.
In my case, moving 'signingConfigs' manually above 'buildTypes' didn't work, but produced a different error. So, what I did is delete 'signingConfigs' section altogether and generated 'signingConfigs' via 'File'>'Project Structure' -> 'Signing Configs'.
It automatically generated 'signingConfigs' and errors disappeared. It placed 'signingConfigs' like in a picture below