Android studio Failed to resolve Facebook SDK - facebook

I have an issue in Android studio related to Facebook SDK and it's as below :
The build.gradle file (Project) looks like this :
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
url 'https://maven.google.com'
}
}
}
The build.gradle file (Module:app) looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 5
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
}
Repositories are well added but i can't figure out the issue.
Many thanks.

Related

ERROR: Task failed with an exception build.gradle' line: 25

I have seen many similar questions, but none of the solutions fixed my problem. I get the following error on vscode.
Where: Build file 'E:\Download\Chatter-App-master\Chatter-App-master\android\app\build.gradle'
line: 25
What went wrong: A problem occurred evaluating project ':app'.
Plugin with id 'kotlin-android' not found
.
here the build gradle code
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.myfirst_flultter_project"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 19
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so flutter run --release works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:2.0.1'
}

How to sign an Android application for publishing on playstore

when I try to publish my unity games on google developer, I always have this error:
Failed to import. You have imported an APK or Android App Bundle that
can be debugged. For security reasons, you must disable debugging
before the applicable APK or Android App Bundle can be published on
Google Play. Learn more about APKs or Android Bundle Bundle packages
for which the Debug feature has been enabled.
You have imported an APK or an Android App Bundle with a signature in debug mode. You must sign it in output version mode. Learn more about the signature.
I think there are something in maintemplate.gradle to change:
this is my mainTemplate:
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
release {
// Set minifyEnabled to true if you want to run ProGuard on your project
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debbugable false
**SIGNCONFIG**
signingConfig signingConfigs.firstapp
}
}
}
Just make sure your settings are like this -

java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class

When I add facebook sdk dependencies to my android studio project, I have faced the issue :
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please help me to resolve this issue .
Here is my build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.1"
aaptOptions {
cruncherEnabled = false
}
defaultConfig {
applicationId "com.HN.xxx"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:support-v4:25'
compile ('com.facebook.android:facebook-android-sdk:4.+') {
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'

Android Gradle dexcount-gradle-plugin

I read the documentation but I could not make it. I am using Android Studio 2.0 Stable version.
This is my project level build.gradle file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is app module level build.gradle file :
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
}
}
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
dexcount {
format = "list"
includeClasses = false
includeFieldCount = true
includeTotalMethodCount = false
orderByMethodCount = false
verbose = false
maxTreeDepth = Integer.MAX_VALUE
teamCityIntegration = false
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
}
}
ext {
supportLibVersion = '23.3.0'
googlePlayServicesVersion = '8.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
// eventbus
compile 'org.greenrobot:eventbus:3.0.0'
// rate me dialog
compile 'com.github.hotchemi:android-rate:0.5.6'
// apache commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}
this is giving error everytime :
Error:(11, 0) Dexcount plugin requires the Android plugin to be configured
what is the solution of this error ?
SOLUTION
I shifted the line of
"apply plugin: 'com.android.application'"
with
"apply plugin: 'com.getkeepsafe.dexcount'"
and it's worked
It is documented in Dex count's GitHub repo:
// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'
So as you said, just make sure that the Android plugin is before the Dex count plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'

Android Log in with Twitter

I'm trying to integrate twitter login in my application, however not able to succeed yet.
https://dev.twitter.com/twitter-kit/android/twitter-login
In the above link it asks us to install Twitter Core library
dependencies {
compile('com.twitter.sdk.android:twitter-core:1.3.1#aar') {
transitive = true;
}
}
However, this library isn't being downloaded. I always throws an error
Failed to resolve: com.twitter.sdk.android:twitter-core:1.3.1
What should i do?
I have just solved your problem using the next instructions:
Inside your build.gradle (general):
your build script must be like this:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
2.Your build.gradle (app) must be like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile('com.twitter.sdk.android:twitter:1.5.1#aar') {
transitive = true
}
}
If you have any question, try to take a look this link:
https://github.com/twitter/twitter-kit-android
It works for me! Hope it helps!