I am using Jake Wharton's Double Espresso library for setting up Instrumentation tests in my app. The tests run fine on my phone but crash on any virtual device (I tried an emulator and Genymotion device).
The error I get is the IllegalAccessError that has been reported [previously]((Instrumentation run failed due to 'java.lang.IllegalAccessError'. Gradle + Espresso). However, what puzzles me is why it only happens on virtual devices. The setup should be fine if it's able to run on physical devices.
The stacktrace includes errors all over the place but the one reported as fatal is :
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at com.myApp.onCreate(MyApp.java:32)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
In any case, I tried excluding all the libraries that could have possible clashes but I still can't get it to work. Does anyone have any ideas on what the issue might be or even how to troubleshoot ?
The problem does seem to be related to daggger which is being used in the app as well. MyApp:32 points to the line where ObjectGraph is created and the following two lines are in the stacktrace.
W/dalvikvm﹕ Class resolved by unexpected DEX: Lcom/myApp/MyApp;(0xa4df7388):0x97542000 ref [Ldagger/ObjectGraph;] Ldagger/ObjectGraph;(0xa4df7388):0x97add000
W/dalvikvm﹕ (Lcom/myApp/MyApp; had used a different Ldagger/ObjectGraph; during pre-verification)
**UPDATE: ** The issue is likely related to the Dalvik VM on the virtual devices. My phone is set to ART and similar issues with Dalvik have been reported previously. It should be fixed by adding the following:
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'com.squareup.dagger'
}
as per the library page but that doesn't seem to help.
The issue was actually caused by the espresso-support library. I needed to add com.squareup.dagger as an exclusion there too while I was only adding exclusions to the other library.
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'com.squareup.dagger'
}
androidTestCompile ('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
exclude group: 'com.squareup.dagger' // this goes here too
exclude group: 'com.android.support', module: 'support-v4'
}
Related
FATAL EXCEPTION: main
Process: com.example.sellit, PID: 21402
java.lang.VerifyError: Verifier rejected class com.google.firestore.v1.Value: void com.google.firestore.v1.Value.mergeGeoPointValue(com.google.type.LatLng) failed to verify: void com.google.firestore.v1.Value.mergeGeoPointValue(com.google.type.LatLng): [0x19] register v4 has type Precise Reference: com.google.type.LatLng but expected Reference: com.google.protobuf.GeneratedMessageLite
void com.google.firestore.v1.Value.mergeTimestampValue(com.google.protobuf.Timestamp) failed to verify: void com.google.firestore.v1.Value.mergeTimestampValue(com.google.protobuf.Timestamp): [0x19] register v4 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLite (declaration of 'com.google.firestore.v1.Value' appears in /data/app/~~f45OKSRu4zvHtUGPkqm61Q==/com.example.sellit-ypy_xq8iBTIqr4GuT8n7Ag==/base.apk!classes8.dex)
at com.google.firestore.v1.Value.getDefaultInstance(Value.java:1862)
at com.google.firestore.v1.MapValue$FieldsDefaultEntryHolder.<clinit>(MapValue.java:29)
at com.google.firestore.v1.MapValue.dynamicMethod(MapValue.java:421)
at com.google.protobuf.GeneratedMessageLite.dynamicMethod(GeneratedMessageLite.java:308)
at com.google.protobuf.GeneratedMessageLite.buildMessageInfo(GeneratedMessageLite.java:376)
at com.google.protobuf.GeneratedMessageInfoFactory.messageInfoFor(GeneratedMessageInfoFactory.java:60)
at com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory.messageInfoFor(ManifestSchemaFactory.java:144)
at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:56)
at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:91)
at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:105)
at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:226)
at com.google.protobuf.GeneratedMessageLite.registerDefaultInstance(GeneratedMessageLite.java:411)
at com.google.firestore.v1.MapValue.<clinit>(MapValue.java:466)
at com.google.firestore.v1.MapValue.newBuilder(MapValue.java:228)
at com.google.firebase.firestore.UserDataReader.parseMap(UserDataReader.java:290)
at com.google.firebase.firestore.UserDataReader.parseData(UserDataReader.java:251)
at com.google.firebase.firestore.UserDataReader.convertAndParseDocumentData(UserDataReader.java:232)
at com.google.firebase.firestore.UserDataReader.parseSetData(UserDataReader.java:75)
at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:167)
at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:147)
at com.example.sellit.SignUpActivity$2.onComplete(SignUpActivity.java:79)
at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks##18.0.1:1)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I am making an android app that uses firebase firestore for database. However I get the above error everytime I press the signup button.
I am calling this function in my signupactivity.java class
firebaseFirestore.collection(DATA_USERS).document(firebaseAuth.getUid()).set(user);
I have no idea how to fix this please help..
Ive tried:
in my build.gradle
implementation ('com.google.firebase:firebase-firestore:24.4.0'){
exclude module: 'protolite-well-known-types'
exclude module: 'protobuf-javalite'
exclude module: 'protobuf-java'
exclude module: 'protobuf-java-util'
//exclude module: "com.google.protobuf"
exclude module:'protobuf-lite'
exclude module:'proto-google-common-protos'
}
but this does not work.
I am using Firebase Crash Reporting and Firebase Remote Config. Version of both is 9.8.0.
On most devices setup works perfectly (I followed Set up crash reporting). But on small percentage of devices (it is actually crash with the highest occurrence) it crashes when I try to initialize Remote Config in Application onCreate method.
java.lang.RuntimeException: Unable to create application com.company.application.AppApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6429)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.a.d(Unknown Source)
at com.google.firebase.b.a.a(Unknown Source)
at com.company.application.d.a.a(SourceFile:21)
at com.company.application.AppApplication.onCreate(SourceFile:76)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6426)
... 8 more
Prior to version 10.0.0, Firebase Crash created an additional process in your app named background_crash. An instance of your AppApplication class is created and executed for each process in your app, including background_crash.
If you want to perform initialization of Firebase services in your application class, you need to add a guard to prevent the initialization from being performed in background_crash. On way to do that is:
if (!FirebaseApp.getApps(this).isEmpty()) {
// Not in crash process. Do your Remote Config init here.
}
Another solution is to upgrade to the latest version of Firebase, 10.0.1.
Assuming this answer is valid, I can't explain why the failure only occurs on some devices, unless the version of Google Play Services installed on the device is a factor, and the failing devices have an older version.
set classpath 'com.google.gms:google-services:4.0.1' in dependencies.
Implement the androidTestImplementation dependencies :
androidTestImplementation('com.android.support.test.espresso:espresso-core:.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
I want to use jsoup so I downloaded the jsoup-1.9.2.jar file and moved it in my libs folder in Android Studio. When I tried to build the project I get the following error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.jsoup/jsoup/pom.xml
File1: /Users/David/AndroidStudioProjects/Vertretungsplan2/app/libs/jsoup-1.9.2.jar
File2: /Users/David/.gradle/caches/modules-2/files-2.1/org.jsoup/jsoup/1.9.2/5e3bda828a80c7a21dfbe2308d1755759c2fd7b4/jsoup-1.9.2.jar
I tried several things suggested all around Google. I excluded these files in the build.gradle:
exclude 'org/jsoup/nodes/entities-full.xml'
exclude 'org/jsoup/nodes/entities-full.properties'
exclude 'META-INF/maven/org.jsoup/jsoup/pom.xml'
exclude 'META-INF/maven/org.jsoup/jsoup/pom.properties'
exclude 'org/jsoup/nodes/entities-base.properties'
exclude 'org/jsoup/nodes/entities-base.xml'
This let Android Studio build the project successfully but whenever I try to use jsoup I get the following error:
08-14 18:52:53.852 8200-8906/de.gymnasium_beetzendorf.vertretungsplan E/AndroidRuntime: FATAL EXCEPTION: IntentService[RefreshService]
Process: de.gymnasium_beetzendorf.vertretungsplan, PID: 8200
java.lang.ExceptionInInitializerError
at org.jsoup.nodes.Entities.access$000(Entities.java:17)
at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:20)
at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:371)
at org.jsoup.nodes.Document.<init>(Document.java:18)
at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:29)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:52)
at org.jsoup.parser.Parser.parseInput(Parser.java:30)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:136)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:653)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:217)
at de.gymnasium_beetzendorf.vertretungsplan.RefreshService.doStuff(RefreshService.java:252)
at de.gymnasium_beetzendorf.vertretungsplan.RefreshService.onHandleIntent(RefreshService.java:93)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.NullPointerException: in == null
at java.util.Properties.load(Properties.java:246)
at org.jsoup.nodes.Entities.loadEntities(Entities.java:241)
at org.jsoup.nodes.Entities.<clinit>(Entities.java:225)
at org.jsoup.nodes.Entities.access$000(Entities.java:17)
at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:20)
at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:371)
at org.jsoup.nodes.Document.<init>(Document.java:18)
at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:29)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:52)
at org.jsoup.parser.Parser.parseInput(Parser.java:30)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:136)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:653)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:217)
at de.gymnasium_beetzendorf.vertretungsplan.RefreshService.doStuff(RefreshService.java:252)
at de.gymnasium_beetzendorf.vertretungsplan.RefreshService.onHandleIntent(RefreshService.java:93)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
I have no idea what I have to do to solve this so any help is appreciated. If my post is missing any information you guys need just let me know. Thanks!
Java code that uses jsoup:
public void doStuff () {
String url = "http://gymnasium-beetzendorf.de/uorganisation/vplan.html";
try {
Document document = Jsoup.connect(url).get();
Elements div = document.select("div.content");
Elements a = div.select("a");
Log.i(MainActivity.TAG, "anzahl der links " + String.valueOf(a.size()));
} catch (IOException e) {
e.printStackTrace();
}
}
Your Gradle error is stating there are duplicate files that are conflicting between the JAR file, and the compiled Gradle dependency, which you probably have this in your dependencies.
compile 'org.jsoup:jsoup:1.9.2'
Therefore, you shouldn't need to download a JAR file, or exclude anything, you can simply use that library.
I am getting this crash in about 70% of devices in the market. However it never came up during testing.
public class MyApp extends Application{
public void onCreate() {
super.onCreate();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
}
This is the error.
Fatal Exception: java.lang.RuntimeException: Unable to create application com.mycompany.myapp.activities.MyApp: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4927)
at android.app.ActivityThread.access$1500(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at com.google.android.gms.internal.aa.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.d(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.android.gms.internal.z.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.c(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.tesseractmobile.solitairesdk.activities.SolitaireApp.onCreate(SolitaireApp.java:123)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4924)
I am using firebase 9.2.1
compile "com.google.firebase:firebase-core:${firebaseVersion}"
compile "com.google.firebase:firebase-database:${firebaseVersion}"
//For dynamic links
compile "com.google.firebase:firebase-invites:${firebaseVersion}"
//Authentication - for logging winning games
compile "com.google.firebase:firebase-auth:${firebaseVersion}"
Right now I am just disabling firebase in our app. We were just testing it to see how stable it is. I have no clue why it worked on all of our test devices then crashed this bad in the wild.
Update:
I was able to get a video of the issue using Firebase Test Lab. It happened when the robotest clicked on an Ad (Ad supported app) then came back to the app. So maybe it has something to do with FirebaseAuth.getInstance().signInAnonymously(); getting called twice? However Application.onCreate() should only be called once. I know there is a known bug with Firebase crash reporting that will cause two Application instances to be created but we are not using that sdk util they fix the issue.
I used Firebase Test Lab to find the issue. It crashed on one of their devices and I watched the video of what happened. Our app is ad supported. We don't click our own ads during testing so this never came up. The crash happens after a user clicks an ad and then reenters the app. The solution I found was the same as this issue. FirebaseApp with name [DEFAULT] doesn't exist
if (!FirebaseApp.getApps(this).isEmpty()){
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
I think Application.onCreate() is called more than once. Though that should never happen.
EDIT: THIS ANSWER DOES NOT WORK
After a full week of testing by a 4 person QA team. Running 58 unit and connected tests with espresso on 7 test devices. Then running multiple tests on dozens of cloud devices using Google Test Lab. The problem never happened. Then on release day, 500 crashes in the first half hour!? 70% crash rate. So back to square one.
FINAL ANSWER: Proguard issue
I added these two line to my proguard-rules.pro
#Firebase Authentication
-keepattributes Signature
-keepattributes *Annotation*
Problem solved.
Hi I have a similar problem, after days without solution, I found what it's a version problem with the appcompat, so i Changed this:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
to this:
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
in the app graddle and my problem solved, sorry for my English
Update your build.gradle:
// Firebase Gradle
compile "com.google.firebase:firebase-auth:9.4.0"
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
today i added the google play services library to my project. I have followed the instructions which are given on http://developer.android.com/google/play-services/setup.html#ensure
Screenshot of my Settings: https://drive.google.com/file/d/0Bwe9sI6XZ6rcZGZzdmlaQjVheDA/edit?usp=sharing
The problem is when I try to execute the following code, a noclassdeffounderror exception raises.
public class MainActivity extends Activity {
private GoogleApiClient mGoogleClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
mGoogleClient = new GoogleApiClient.Builder(this)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
.build();
In the logcat the exception looks like
threadid=1: thread exiting with uncaught exception (group=0x40d02930)
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.common.api.GoogleApiClient$Builder
at com.gmail.mhofer4991.at.taptorotate.MainActivity.onCreate(MainActivity.java:104)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$600(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5074)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Force finishing activity com.example.taptorotate/com.gmail.mhofer4991.at.taptorotate.MainActivity
I also have cleaned and rebuilt the project.
It's driving me crazy that i cannot solve the problem. I know there are already other threads with the same topic and I also tried some solutions which were suggested there but none of them worked for me. Please help me out!
I also had same problem,
java.lang.NoClassDefFoundError:
com.google.android.gms.common.api.GoogleApiClient$Builder
I was using the below dependency on the application build.gradle file.
compile 'com.google.android.gms:play-services:7.8.0'
I changed it to
compile 'com.google.android.gms:play-services-plus:7.8.0'
I updated the Google Play Services (Rev 26) and Google Repository(Rev 20).
After that the exception doesn't occur.
Try to use individual APIs and corresponding build.gradle descriptions as mensioned in the following page,
https://developers.google.com/android/guides/setup#ensure
Try to add obfuscation rules for the Google API's if you have minifyEnabled or ProGuard set to true:
ProGuard Configuration
tryin to work with an implementation of Google Drive in Android i´ve found this error message pointing some classes like:
java.lang.ClassNotFoundException: com.google.android.gms.common.api.Scope
Caused by: java.lang.ClassNotFoundException: Didn't find class
I have found that the real problem is the limit of 64K references when we add dependencies related to GoogleApiClient, so adding multidex support solved my problem:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
...
...
multiDexEnabled true
}
...
...