Program type already present error in android while using face-book login? - java

I have implemented a facebook login on my application. While compile it does not shows any error message but when I run my code it shows
" Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat "
this error. I have used code from this link ( " http://androidlift.info/2016/01/01/facebook-login-android-example/ " ). Here is the gradle code.
build.gradle(Project: XYZ)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.admin.photeditor"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.facebook.android:facebook-android-sdk:4.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
Android.Manifest.xml
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<activity android:name=".FBMainActivity"></activity>
Kindly suggest why I am getting such error or Is there any error in my code?
Thanks in advance

Related

Why is my application only compatible with 14 devices on google play?

I am editing an App code. Only the front.
I am facing with the problem that the application runs over any device in debug mode, but, once I upload to google play the application is just comptible with 14 devices. ┬┐14? ┬┐Really?. I dont understand. It is very weird.
This is what is google showing me: https://imgur.com/a/R8Rgj
This all I have declared app use in the manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This is de app build.gradle:
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.my.app.name"
minSdkVersion 11
targetSdkVersion 21
versionCode 68
versionName "v2.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
androidTest {
setRoot('src/test')
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
repositories {
flatDir {
dirs 'aars'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: '../core/libs', include: ['*.jar'])
compile project(':core')
compile 'com.android.support:gridlayout-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.findbugs:jsr305:1.3.9'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.google.protobuf:protobuf-java:2.5.0'
compile 'com.google.zxing:core:3.1.0'
compile 'ch.acra:acra:4.5.0'
compile 'com.android.support:support-v4-preferencefragment:1.0.0#aar'
}
IDK if there is another place where could be limiting the devices.
IDK if it is a peace af code doing this. The first time I am facing it.
Thanks in advance.
UPDATE
As you can see in the pic, the platform only refers to x86_64. iDK if this is the problem. If it is the case, any idea how to solve it? please?
As of 9/10/2017 and this answer will be outdated super fast, your app is not targeting the latest API, try targeting the API 26 Android O.
Change these and rebuild to the latest API 26 and update the dependencies
compileSdkVersion
buildToolsVersion
targetSdkVersion
Right now Google supports the SDK on 14+ minimum SDK.So,it is generally preferriable to make youa apps minimum SDK to 14.Many of the apps SDK is functional and better for that minimum SDK value

Android Custom Multidex Application Error

I'm trying to create an Android Application Class that extends MultidexApplication.
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
registerParseSubClasses();
parseInit();
}
private void registerParseSubClasses() {
//registering subclasses
ParseObject.registerSubclass(UserPlace.class);
ParseObject.registerSubclass(PlaceItem.class);
ParseObject.registerSubclass(PlaceItemRating.class);
}
private void parseInit() {
Parse.initialize(new Parse.Configuration.Builder(getBaseContext())
.applicationId("MYAPPID")
.server("MyURL")
//.enableLocalDataStore()
.build());
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
ParseFacebookUtils.initialize(this);
}
}
And my Android Manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pnametala.application" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
and here's my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.pnametala.application"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.parse:parse-android:1.13.1'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.weiwangcn.betterspinner:library:1.1.0'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.facebook.android:facebook-android-sdk:4.15.0'
compile 'com.parse:parsefacebookutils-v4-android:1.10.3#aar'
}
If i use MultidexApplication in My AndroidManifest.xml, it works like a charm but I need to input some init overrides that can't be done without that.
The stack trace is:
Unable to instantiate application com.pnametala.application.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.pnametala.application.MyApplication" on path: DexPathList[[zip file "/data/app/com.pnametala.application-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.pnametala.application-1, /vendor/lib, /system/lib]]
Anyone knows a solution?
Add this to your build.gradle
dexOptions {
javaMaxHeapSize "4g"
}
For me, what resolved the question was split the google-play-service lib in parts, as described here.
I just import the libs that I realy need to use (like maps and adress api).
For now, I'm not using Multidex anymore.

Android - Execution failed for task ':app:transformClassesWithMultidexlistForDebug'

When I attempt to run my very simple android application I get the following output:
Information:Gradle: Executing tasks: [:app:assembleDebug]
Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16,
11:25 AM - Compilation completed with 1 error and 0 warnings in 6s
706ms
Error:Gradle: Execution failed for task
':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
I had originally not been using multidex and I was getting a similar error with the standard dex. Here is the original output I was getting without multidex:
Information:Gradle: Executing tasks: [:app:assembleDebug]
Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16,
11:28 AM - Compilation completed with 1 error and 0 warnings in 7s
624ms
Error:Gradle: Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
I think I've tried every conceivable solution and nothing works.
Here is my application level build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc4"
defaultConfig {
applicationId "com.example.XXX.testapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
// debug {
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental = true;
javaMaxHeapSize "4g"
//preDexLibraries = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
I have tried running with various combinations of lines commented and uncommented as you can see, to no avail.
I have no files in my "lib" folder.
Here is my higher-level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// 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 here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXX.testapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:name="android.support.multidex.MultiDexApplication"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
If you are going to integrate multidex support then you need to do that in a apprehensive manner.
From this link
Try doing the following changes:
Add multiDexEnabled true to your gradle file in the defaultConfig closure.
In your manifest add the MultiDexApplication class from the support library as follows:`
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
`
Also note that, if you are already having an Application class for your project, override the method called attachBaseContext() and in that method call:
MultiDex.install(this)

Android service not working on 5.1.1 version

I have a serious problem with Service on Android, specifically in version 5.1.1, well, I have an app that should run a service in the background all the time, I've done other app before Android 5.0, and it always worked, the problem is that In version 5.1.1 Service is not running when the user swipe it off from recent activity, it does not work.
I already researched a lot and can not find any solution, please help me.
EDIT:
My service (Firebase Cloud Messaging):
<service android:name=".service.FirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".service.FirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
My gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "br.com.thiengo.firebasenotification"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
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:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'org.greenrobot:eventbus:3.0.0'
}
apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml - specified for property 'manifest' does not exist

This is the error I'm getting and one that is seemingly unfixable from what I've been searching through on StackOverflow.
Error:A problem was found with the configuration of task ':checkDebugManifest'.
> File '/Users/wasimsandhu/AndroidStudioProjects/Conjugation/src/main/AndroidManifest.xml'
specified for property 'manifest' does not exist.
I keep getting this error every time I rebuild the project or sync Gradle files. I have tried solutions in various other threads here to no avail.
Here is my app/build.gradle file:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
// removed for this post
}
}
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.wsandhu.conjugation"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "0.5"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'de.cketti.library.changelog:ckchangelog:1.2.1'
compile 'com.nispok:snackbar:2.0.1'
}
And here is the build.gradle file in the root directory:
apply plugin: 'com.android.application'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.wsandhu.conjugation"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "0.5"
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wsandhu.conjugation" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And here is the gradle wrapper file, in case that is important:
#Mon Nov 17 20:04:45 PST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
I apologize in advance for the bad formatting or if anything is unclear.
Remove this chunk of code from your build.gradle in the root directory
apply plugin: 'com.android.application'
and
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.wsandhu.conjugation"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "0.5"
}
}
As it says that:
// NOTE: Do not place your application dependencies here; they belong in the individual module build.gradle files
Meaning this line of code goes to in the gradle file inside your app folder.
Try making your top gradle file like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
I had the same problem before. So I think this will solve your case.

Resources