Java Error on Android Studio java.lang.IllegalAccessError - java

I've already read questions about this problem (This and this) and I've tried to apply the solutions to my case but it didn't work for me
The line who causes an error is this
InstanceID instanceID = InstanceID.getInstance(LoginActivity.this);
Whit this error on Log
java.lang.IllegalAccessError: Method 'void
android.support.v4.content.ContextCompat.' is inaccessible to class
'com.google.android.gms.iid.zzd'
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '25.0.0'
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
defaultConfig {
applicationId "there is an id here"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
lintOptions {
abortOnError false
disable 'InvalidPackage'
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
mavenCentral()
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {
exclude group: 'com.android.support', module: 'multidex'
}
compile 'com.commonsware.cwac:cam2:0.4.+'
compile 'com.google.android.gms:play-services:8.3.0'
compile project(':viewPagerIndicator')
compile 'com.facebook.android:facebook-android-sdk:4.26.0' //CAMBIO DA 4.7.0 a 4.26.0
//compile project(':facebook')
/*compile files('libs/android-maven-plugin-3.6.0.jar')
compile files('libs/apache-mime4j-benchmark-0.7.2.jar')
compile files('libs/apache-mime4j-core-0.7.2.jar')
compile files('libs/apache-mime4j-dom-0.7.2.jar')
compile files('libs/apache-mime4j-examples-0.7.2.jar')
compile files('libs/apache-mime4j-storage-0.7.2.jar')
compile files('libs/braintree-api-1.2.7.jar')
compile files('libs/commons-codec-1.6.jar')
compile files('libs/fluent-hc-4.2.1.jar')
compile files('libs/httpclient-4.2.1.jar')
compile files('libs/httpclient-cache-4.2.1.jar')
compile files('libs/httpcore-4.2.1.jar')
compile files('libs/httpmime-4.2.1.jar')
compile files('libs/libGoogleAnalytics.jar')
compile files('libs/metadata-extractor-2.6.2.jar')
compile files('libs/xmpcore.jar')*/
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}

Exclude Support Library from facebook SDK
compile ('com.facebook.android:facebook-android-sdk:4.26.0'){
exclude module: 'support-v4'
exclude group: 'com.android.support'
}

Related

Android studio failed to instantiate one or more classes after update to SDK 26

After downloading SDK 26 and updated my project I had some library conflicts which I successfully fixed. But I have this persistent issue that it is tackled nowhere in the forums or SO.
My XML preview is broken. I can build and run the program but I can't see anything because of that:
I tried:
Changing the theme from Theme.AppCompat.Light.DarkActionBar to
Base.Theme.AppCompat.Light.DarkActionBar
Updating my gradle in a similar way
Invalidate Cache / Restart
Checked and updated all my libraries and removed all errors regarding gradle
Changed the api on the preview
All SDKs are updated.
Everything was fine right before I update to SDK 26. All the solutions available do nothing. Help would be very much appreciated
EDIT
my gradle.build
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 {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "gr.softweb.sakouli"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(path: ':linkedin-sdk')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
// configurations.all {
// resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// def requested = details.requested
// if (requested.group == 'com.android.support') {
// if (!requested.name.startsWith("multidex")) {
// details.useVersion '26.0.1'
// }
// }
// }
// }
compile 'com.facebook.android:facebook-android-sdk:4.26.0'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:customtabs:26.0.0'
compile 'com.koushikdutta.ion:ion:2.2.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.roughike:bottom-bar:2.3.1'
compile 'com.ncapdevi:frag-nav:2.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'co.lujun:androidtagview:1.1.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.braintreepayments.api:drop-in:3.1.0'
testCompile 'junit:junit:4.12'
apply plugin: 'com.google.gms.google-services'
}
Updating the following:
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
to the following solved the problem for me:
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.myandroidgoogleappengine"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:11.2.2'
}
apply plugin: 'com.google.gms.google-services'
I had the same problem .Just updated 26.0.0 to 26.0.0-alpha1 and the problem is solved.

Error Build APK Error:Execution failed for task ':app:transformClassesWithDexForRelease'

Error Bulid APK
What problem in this code? Firebase? I try clean and rebuild. But I have this error.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class
My app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "myapp.over.app"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'me.anwarshahriar:calligrapher:1.0'
compile 'com.github.mvpotter:kladr-api-client:0.6.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
What I need doing?
this happened to me once, the problem specifically was
duplicate entry: javax/inject/Inject.class
so I checked my dependencies and found that I got multiple declaration of dependencies, so go in to you libs folder and check if there is a jar file that is also declared in your dependencies
compile fileTree(include: ['*.jar'], dir: 'libs')
most probably one of these are already in your libs folder:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'me.anwarshahriar:calligrapher:1.0'
compile 'com.github.mvpotter:kladr-api-client:0.6.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
Problem in Maven.
Maven can`t be include in Gradle.

ERROR. Can't create release apk

I try to create signed apk but Android Studio gives me this error.
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list C:\Users\azats\Desktop\App\app\build\intermediates\multi-dex\release\maindexlist.txt --output C:\Users\azats\Desktop\App\app\build\intermediates\transforms\dex\release\folders\1000\1f\main C:\Users\azats\Desktop\App\app\build\intermediates\transforms\jarMerging\release\jars\1\1f\combined.jar}
I cleaned and build the project multiple times and also multidex is enabled in my build.gradle file.
Here is my gradle file
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
signingConfigs {
config {
keyAlias 'key1'
keyPassword 'torres1984'
storeFile file('C:/Users/azats/Desktop/release-keystore.jks')
storePassword 'aniki1995'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.makeuprewardz.app"
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName "4.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
dexOptions {
javaMaxHeapSize "2g"
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/MANIFEST.MF'
}
}
repositories {
mavenCentral()
maven { url "https://bitbucket.org/adscend/androidsdk/raw/master/" }
maven { url "https://jitpack.io" }
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.medyo:fancybuttons:1.8.3'
compile 'com.google.code.gson:gson:2.8.0'
compile 'me.yokeyword:fragmentation:0.10.4'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'jp.wasabeef:glide-transformations:2.0.2'
compile 'com.afollestad.material-dialogs:core:0.9.4.4'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.jude:easyrecyclerview:4.4.0'
compile 'com.github.GrenderG:Toasty:1.1.3'
compile 'com.github.medyo:android-about-page:1.2'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.android.gms:play-services-iid:11.0.1'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.github.lygttpod:SuperTextView:1.1.2'
compile 'com.brucetoo.pickview:library:1.2.3'
compile 'com.zhihu.android:matisse:0.4.3'
compile 'me.weyye.hipermission:library:1.0.3'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.squareup.okio:okio:1.12.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.network.connectionclass:connectionclass:1.0.1'
compile 'com.facebook.android:audience-network-sdk:4.21.1'
compile 'com.google.android.gms:play-services-basement:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'io.github.kobakei:ratethisapp:1.2.0'
compile 'com.kyleduo.switchbutton:library:1.4.6'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.adscendmedia.sdk:adscendmedia:2.3.2'
compile 'com.pollfish:pollfish:+:googleplayRelease#aar'
compile(name: 'OfferToroSdk-v3.1.3', ext: 'aar')
compile(name: 'adgatemediasdk', ext: 'aar')
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile files('libs/SuperRewards-3.1b.jar')
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
apply plugin: 'com.google.gms.google-services'

Android Studio-Error:Execution failed for task ':app in

When I run my app I am getting these error is something pointing to graphics/drawable. I searched through various websites but none of that gave solution.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/graphics/drawable/DrawableCompat.class
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.rajkumar.layout"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'gr.pantrif:easy-android-splash-screen:0.0.1'
compile 'com.felipecsl:gifimageview:2.1.0'
compile 'commons-io:commons-io:2.4'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
testCompile 'junit:junit:4.12'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
}
Can Anyone help me how to solve this issue.
Thank You
You have to exclude the module
compile 'com.android.support:support-v4:23.0.1'
compile ('com.android.support:appcompat-v7:25.3.1') {
exclude module: 'support-v4'
}
compile ('pl.droidsonroids.gif:android-gif-drawable:1.1.17') {
exclude module: 'support-v4'
}
compile ('com.felipecsl:gifimageview:2.1.0') {
exclude module: 'support-v4'
}

Error Build APK {duplicate entry: com/google/android/gms/gcm/INetworkTaskCallback$Stub.class}

Hi i am trying to build APK but i Fetching this problem in Android Studio.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/INetworkTaskCallback$Stub.class
Gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.mouad.fixmyphone"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The documentation for Firebase JobDispatcher says to include only one of these:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
You are including both. Because your app does not have a dependency on com.google.android.gms:play-services-gcm, you should only include this library:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
Remove this line from your dependencies:
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'

Categories