java.lang.IllegalStateException: Module adapter - android

Hi all I want to use ObjectGraph in android I am using following
applicationGraph = ObjectGraph.create(getModules().toArray());
applicationGraph.inject(this);
But it gives me error as :
java.lang.RuntimeException: Unable to create application com.my.mynews.app.MyApplication: java.lang.IllegalStateException: Module adapter for class com.my.mynews.b.b could not be loaded. Please ensure that code generation was run for this module.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalStateException: Module adapter for class com.my.mynews.b.b could not be loaded. Please ensure that code generation was run for this module.
at a.a.j.a(Unknown Source)
at a.a.j.a(Unknown Source)
at a.a.x.b(Unknown Source)
at a.a.i.a(Unknown Source)
at a.a.z.a(Unknown Source)
my build.gradle is like:
configurations {
apt
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.jakewharton:butterknife:5.0.+'
compile 'com.jakewharton.timber:timber:2.2.+'
compile 'com.squareup.dagger:dagger:1.2.+'
//provided 'com.squareup.dagger:dagger-compiler:1.2.+'
apt 'com.squareup.dagger:dagger-compiler:1.2.+'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.+'
compile 'com.github.satyan:sugar:1.3'
compile 'com.pnikosis:materialish-progress:1.2'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.google.android.gms:play-services-analytics:7.0.0'
compile files('libs/volley.jar')
}
If I uncomment provided in above dependencies and comment apt and make minifyEnabled false then it works perfectly. But I want to reduce code size therefore I have done minifyEnabled true and application crashesh.
Any suggestion will be appreciated. Thanks in advance

I ran into a similar problem myself. Unfortunately, Dagger 1.2+ does not appear to play nicely with proguard's minifyEnabled. So the best options I could find are:
Set minifyEnabled false and just deal with it
Upgrade to Dagger 2.0 (here's a guide: http://frogermcs.github.io/dagger-1-to-2-migration/)
Some people have had luck downgrading to Dagger 1.0.1 and eliminating dagger-compiler altogether (https://stackoverflow.com/a/23954164).

Related

How to add .jar files in android studio which include class name like TranslateOptions$TranslateDefault.class

I am trying to add Google cloud Translate Library in android studio. I have some issues to add it directly through dependency. So i add jar files. But when i added jar file in lib folder it automatically exclude Classes which have '$' this character in there name. Like TranslateOptions$TranslateDefaults.class. This file shown in zip but after adding in android studio this file is not there. And program shows an error that this file is missing. Error
FATAL EXCEPTION: main
Process: edu.nic.dell.naseemchatbot, PID: 15685
java.lang.NoClassDefFoundError:
com.google.cloud.translate.TranslateOptions$TranslateDefaults
at
com.google.cloud.translate.TranslateOptions.(TranslateOptions.java:147)
at
com.google.cloud.translate.TranslateOptions.(TranslateOptions.java:39)
at
com.google.cloud.translate.TranslateOptions$Builder.build(TranslateOptions.java:142)
at
edu.nic.dell.naseemchatbot.ChatActivity.translateTextWithOptionsAndModel(ChatActivity.java:938)
at
edu.nic.dell.naseemchatbot.ChatActivity$5.onClick(ChatActivity.java:272)
at android.view.View.performClick(View.java:4766)
at android.view.View$PerformClick.run(View.java:19683)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5538)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
and this my gradle file
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/grpc-google-cloud-speech-v1-0.1.8.jar')
compile files('libs/protobuf-java-3.4.0.jar')
compile files('libs/grpc-protobuf-1.2.0.jar')
compile files('libs/grpc-google-common-protos-0.1.8.jar')
compile files('libs/grpc-core-1.2.0.jar')
compile files('libs/grpc-stub-1.2.0.jar')
compile files('libs/google-cloud-translate-1.14.0.jar')
compile files('libs/google-http-client-1.21.0.jar')
compile project(':google-api-services-translate-v2-rev47-1.22.0')
compile files('libs/google-cloud-core-0.6.0.jar')
compile files('libs/grpc-google-common-protos-0.1.8.jar')

Android app works while used as debugging,but crashes if testing version "app-debug" is installed

Please comment why it was downvoted and what should i add more
Here is logcat output
06-02 15:21:04.520 7986-7986/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mayurn.engineeringhelper, PID: 7986
java.lang.NoSuchMethodError: No static method zzcx(Landroid/content/Context;)Lcom/google/android/gms/internal/zzbth; in class Lcom/google/android/gms/internal/zzbth; or its super classes (declaration of 'com.google.android.gms.internal.zzbth' appears in /data/app/com.example.mayurn.engineeringhelper-2/base.apk:classes12.dex)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5187)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4782)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4722)
at android.app.ActivityThread.access$1600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
In my Build.gradle (Module:app) I have
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And in build.gradle(Project) I have this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have seen these answers
Firebase database dependency crashes app
After upgrading to google play services 8.4.0 my app crashes on startup
No static method zzUr() in Firebase when I try to use Analytics with Notifications
All they suggest to use the same version of firebase services.
You can see that I have already done that, the only version of ui-database and ui-storage are different.
Also short note:-MultiDex is enabled and minify is disabled.
The problem in your dependencies is that your firebaseui library is not compatible with firebase library.
Check Compatibility with Firebase / Google Play Services Libraries.
You want 1.2.0 version of firebaseui and therefore you must update firebase library to 10.2.0+.
In your build.gradle you need to add all the dependencies -
dependencies {
// FirebaseUI Database only
compile 'com.firebaseui:firebase-ui-database:1.2.0'
// FirebaseUI Auth onl
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.2.0'
}
If this doesn't fix your error then you might want to add these files as well
compile "com.android.support:design:23.2.1"
compile "com.android.support:customtabs:23.2.1"
compile "com.android.support:cardview-v7:23.2.1"
I hope after doing all this, your issue should be long gone.
Btw for more information on this, you can check out the Git repo of Firebase - https://github.com/firebase/FirebaseUI-Android#installation actually this has all the details.

java.lang.NoSuchMethodError: No virtual method zzait()Ljava/util/ArrayList; in class Lcom/ Error?

Hi I'm learning to use Firebase from an Udacity Course.
I got this error when I ran my app and have no clue about it.
11-23 16:48:34.995 3947-3947/com.google.firebase.udacity.friendlychat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.udacity.friendlychat, PID: 3841
java.lang.NoSuchMethodError: No virtual method zzait()Ljava/util/ArrayList;
in class Lcom/google/android/gms/auth/api/signin/GoogleSignInOptions;
or its super classes (declaration of 'com.google.android.gms.auth.api.signin.GoogleSignInOptions' appears in /data/data/com.google.firebase.udacity.friendlychat/files/.jrebel/load-dexes/bundle12/libraries24.zip)
at com.google.android.gms.auth.api.Auth$3.zza(Unknown Source)
at com.google.android.gms.auth.api.Auth$3.zzp(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.addApi(Unknown Source)
at com.firebase.ui.auth.util.CredentialsAPI.initGoogleApiClient(CredentialsAPI.java:147)
at com.firebase.ui.auth.util.CredentialsAPI.<init>(CredentialsAPI.java:65)
at com.firebase.ui.auth.ui.ChooseAccountActivity.onCreate(ChooseAccountActivity.java:102)
at android.app.Activity.performCreate(Activity.java:6100)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) at com.zeroturnaround.jrebel.android.agent.JRebelInstrumentation.callActivityOnCreate(SourceFile:93)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
11-23 16:48:35.176 3947-3975/com.google.firebase.udacity.friendlychatE/GED: Failed to get GED Log Buf, err(0)
Can anyone help me?
UPDATE build.gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
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(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
// Firebase
compile 'com.google.firebase:firebase-database:10.0.0'
compile 'com.firebaseui:firebase-ui-database:1.0.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.0.0'
// Firebase Auth
compile 'com.google.firebase:firebase-auth:10.0.0'
}
apply plugin: 'com.google.gms.google-services'
Matching the versions resolves this.
In Compatibility with Firebase / Google Play Services Libraries, it matches
FirebaseUI Version Firebase/Play Services Version
1.0.0 9.8.0
So if dependencies are changed to
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
instead of
compile 'com.google.firebase:firebase-database:10.0.0'
compile 'com.google.firebase:firebase-auth:10.0.0'
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
which is the latest available firebase version for firebaseUI version, the app works fine
This is most likely do to a version incompatibility between Firebase, and FirebaseUI. I ran into the same issue, and spent 30-45 min trying to figure it out. Ultimately what I did in order to keep going with the "Firebase in a Weekend" tutorial was:
git checkout 1.04-firebase-auth-firebaseui-signin
This will switch to the branch at this point in the tutorial. It works fine after doing so.
Maybe not the ideal answer as to what the problem is, but will get you going again with the course.
You just need to add :
compile 'com.google.android.gms:play-services-auth:x.x.x'(find the right version here). They missed to say that you also need to add play-services-auth dependency for google authentication to work.

Error occurs when you use the library com.android.support:design:23.1.1+ in Smart Lock sample app

I downloaded the example of application Smart Lock for passwords from Google.
Is there a solution other than the use of the library <= 23.0.1?
Bug in library?
Error occurs when you use the library com.android.support:design:23.1.1+:
03-31 09:53:18.828 16779-16779/com.google.codelab.smartlock E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.codelab.smartlock, PID: 16779
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
at com.google.codelab.smartlock.MainActivity.setFragment (MainActivity.java:119)
at com.google.codelab.smartlock.MainActivity.access$000(MainActivity.java:37)
at com.google.codelab.smartlock.MainActivity$1.run(MainActivity.java:79)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
FATAL EXCEPTION
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services-auth:8.4.0'
testCompile 'junit:junit:4.12'
}
Android compileSdkVersion is the version of the compiler used in
building the Application .The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs.
For compileSdkVersion 23 You can use bellows
Calling + is not good Approach
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:design:23.2.1'
In this example from Google I changed the following piece of code in MainActivity,java:
private void setFragment(Intent intent) {
...
if (currentTag == null || !currentTag.equals(tag)) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment, tag)
.commit();
}
}
To:
private void setFragment(Intent intent) {
...
if (currentTag == null || !currentTag.equals(tag)) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment, tag)
.commitAllowingStateLoss();
}
}

com.parse.FacebookAuthenticationProvider error

The app works fine until I've modified the graddle file to put the dependecies of new jar files.
This is the dependecies of the graddle of my app:
dependencies {
compile 'com.parse.bolts:bolts-android:1.1.4'
compile 'com.android.support:support-v4:22.0.0'
provided 'com.facebook.android:facebook-android-sdk:3.23.1'
provided files('libs/Parse-1.9.2.jar') //this is the dependence that I've modified
provided files('libs/ParseFacebookUtils-1.8.4.jar')
}
And this is the dependecies of the graddle of the ParseLoginUI (a github project for integrating the facebook and parse login):
dependencies {
// Module dependency on ParseLoginUI library sources
compile project(':calligraphy-2.1.0')
compile project(':ParseLoginUI')
compile fileTree(include: 'ParseCrashReporting-*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:21.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.squareup.picasso:picasso:2.3.4'
}
Now I get this error when the method com.parse.ParseFacebookUtils.initialize is executed:
java.lang.IncompatibleClassChangeError: com.parse.FacebookAuthenticationProvider
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:91)
at com.unisa.unistore.MainApplication.onCreate(MainApplication.java:35)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
at android.app.ActivityThread.access$1600(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5256)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Please, some one can help me?
I've resolved the problem. It seems to be a corrupted jar file or the incompatibility between Parse-1.9.2.jar and ParseFacebookUtils-1.8.4.jar to cause this problem.
Anyway these are the steps that I made to solve the problem:
Recopying the same files again, in the libs directory (i.e. Parse-1.8.4.jar and ParseFacebookUtils-1.8.4.jar);
Substituting Parse-1.9.2.jar with its 1.8.4 version.
I hope that this answer will be useful to someone.
I was getting the same error in my app.
java.lang.IncompatibleClassChangeError: com.parse.FacebookAuthenticationProvider
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:94)
I found the reason that i was using different version of libs that i kept in libs folder.
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'ParseFacebookUtilsV4-*.jar')
Both Parse and ParseFacebookUtilsV4 jar should have same version that i.e.
Parse-1.9.2.jar & ParseFacebookUtilsV4-1.9.2.jar
so user both libs of same version that you downloaded from parse.com .
I hope this will help ~~

Categories

Resources