Problems using rxjava-android - android

I'm trying tu use Rxjava in a project that I have with gradle. I dont have any compile error, but when I run the project my app crash.
12-01 14:40:41.553 1015-1015/? I/dalvikvm﹕ Could not find method rx.Subscription.unsubscribe, referenced from method com.flipper83.protohipster.view.feed.ui.HipsterListFragment.onPause
12-01 14:40:41.553 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve interface method 11579: Lrx/Subscription;.unsubscribe ()V
12-01 14:40:41.553 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0005
12-01 14:40:41.553 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observable;)
12-01 14:40:41.565 1015-1015/? I/dalvikvm﹕ Could not find method rx.concurrency.Schedulers.newThread, referenced from method com.flipper83.protohipster.view.feed.ui.HipsterListFragment.onResume
12-01 14:40:41.565 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve static method 11581: Lrx/concurrency/Schedulers;.newThread ()Lrx/Scheduler;
12-01 14:40:41.569 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0014
12-01 14:40:41.569 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment$1; interface 2027 'Lrx/Observer;'
12-01 14:40:41.569 1015-1015/? W/dalvikvm﹕ Link of class 'Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment$1;' failed
12-01 14:40:41.569 1015-1015/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x148a at 0x1e in Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment;.onResume
12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observer;)
12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observer;)
12-01 14:40:41.577 1015-1015/? I/dalvikvm﹕ Could not find method rx.Observer.onNext, referenced from method com.flipper83.protohipster.view.feed.model.FeedViewModel.notifyFeed
12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve interface method 11578: Lrx/Observer;.onNext (Ljava/lang/Object;)V
12-01 14:40:41.577 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0028
12-01 14:40:41.577 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1; interface 2025 'Lrx/Observable$OnSubscribeFunc;'
12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ Link of class 'Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;' failed
12-01 14:40:41.577 1015-1015/? E/dalvikvm﹕ Could not find class 'com.flipper83.protohipster.view.feed.model.FeedViewModel$1', referenced from method com.flipper83.protohipster.view.feed.model.FeedViewModel.populateFeed
12-01 14:40:41.581 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve new-instance 794 (Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;) in Lcom/flipper83/protohipster/view/feed/model/FeedViewModel;
12-01 14:40:41.581 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0000
12-01 14:40:41.581 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1; interface 2025 'Lrx/Observable$OnSubscribeFunc;'
12-01 14:40:41.581 1015-1015/? W/dalvikvm﹕ Link of class 'Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;' failed
12-01 14:40:41.581 1015-1015/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x145d at 0x02 in Lcom/flipper83/protohipster/view/feed/model/FeedViewModel;.populateFeed
12-01 14:40:41.585 1015-1015/? D/AndroidRuntime﹕ Shutting down VM
12-01 14:40:41.585 1015-1015/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa62ca288)
12-01 14:40:41.585 1015-1015/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.flipper83.protohipster.view.feed.model.FeedViewModel$1
at com.flipper83.protohipster.view.feed.model.FeedViewModel.populateFeed(FeedViewModel.java:43)
I believe that the problem comes from gradle. this is my gradle build.xml.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
sourceSets {
main {
assets.srcDirs = ['assets']
}
}
}
dependencies {
compile 'com.squareup.picasso:picasso:2+'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.squareup.retrofit:retrofit:1.2.+'
compile 'com.netflix.rxjava:rxjava-android:0.14.+'
compile files('lib/Parse-1.3.8.jar')
}
Any Idea??

Yes, I fixed it with:
compile 'com.netflix.rxjava:rxjava-core:0.+'
compile 'com.netflix.rxjava:rxjava-android:0.+'
compile 'com.squareup.retrofit:retrofit:1.5.0'
in my build.gradle.
Thank you

compile 'com.netflix.rxjava:rxjava-core:0.+' is transient dependency by
compile 'com.netflix.rxjava:rxjava-android:0.+', and Gradle automatics resolved this dependency and download

Based on ReactiveX/RxAndroid : https://github.com/ReactiveX/RxAndroid
Its better to use both android and java dependencies:
compile 'io.reactivex:rxandroid:1.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex:rxjava:1.0.14'

Related

Can't integrate Firebase in my Android app

I added new project in my Firebase account like all the time and downloaded google-services.json setting file and successfully install it and the app works however not with firebase service the following is my debug , while the app crash.
please note that this error shows up when i try to add : implementation 'com.google.firebase:firebase-core:16.0.4' and in android studio it shows no error in gradle
10/08 19:55:40: Launching app
$ adb push C:\xxx\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.xxx.insidecartoon
$ adb shell pm install -t -r "/data/local/tmp/com.xxx.xxx"
pkg: /data/local/tmp/com.xxx.xxx
Success
APK installed in 27 s 241 ms
$ adb shell am start -n "com.xxx.xxx/com.xxx.xxx.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.xxx.xxx.test | com.xxx.xxx
Connecting to com.xxx.xxx
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System.out: Sending WAIT chunk
W/ActivityThread: Application com.xxx.xxx is waiting for the debugger on port 8100...
I/dalvikvm: Debugger is active
I/System.out: Debugger has connected
waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8602', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1405)
I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method android.support.v4.content.ContextCompat.createDeviceProtectedStorageContext
W/dalvikvm: VFY: unable to resolve virtual method 565: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method android.support.v4.content.ContextCompat.getCodeCacheDir
W/dalvikvm: VFY: unable to resolve virtual method 573: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method android.support.v4.content.ContextCompat.getColor
W/dalvikvm: VFY: unable to resolve virtual method 574: Landroid/content/Context;.getColor (I)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v4.content.ContextCompat.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 575: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method android.support.v4.content.ContextCompat.getDataDir
W/dalvikvm: VFY: unable to resolve virtual method 577: Landroid/content/Context;.getDataDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v4.content.ContextCompat.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 580: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method android.support.v4.content.ContextCompat.getNoBackupFilesDir
W/dalvikvm: VFY: unable to resolve virtual method 587: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method android.support.v4.content.ContextCompat.isDeviceProtectedStorage
W/dalvikvm: VFY: unable to resolve virtual method 600: Landroid/content/Context;.isDeviceProtectedStorage ()Z
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method android.support.v4.content.ContextCompat.startForegroundService
W/dalvikvm: VFY: unable to resolve virtual method 615: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method com.google.android.gms.internal.measurement.zzsl.init
W/dalvikvm: VFY: unable to resolve virtual method 600: Landroid/content/Context;.isDeviceProtectedStorage ()Z
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0009
V/FA: Registered activity lifecycle callback
D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
I/FirebaseInitProvider: FirebaseApp initialization successful
V/FA: onActivityCreated
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
VFY: unable to find class referenced in signature (Lcom/google/android/gms/ads/internal/client/zze;)
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
I/dalvikvm: Could not find method com.google.android.gms.ads.internal.client.zze.zzb, referenced from method com.google.android.gms.ads.internal.client.zzac.zzH
W/dalvikvm: VFY: unable to resolve virtual method 17122: Lcom/google/android/gms/ads/internal/client/zze;.zzb (Landroid/content/Context;Lcom/google/android/gms/ads/internal/client/AdSizeParcel;Ljava/lang/String;Lcom/google/android/gms/internal/zzew;)Lcom/google/android/gms/ads/internal/client/zzu;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x001f
I/dalvikvm: Could not find method com.google.android.gms.common.internal.zzx.zzb, referenced from method com.google.android.gms.ads.AdRequest$Builder.setContentUrl
W/dalvikvm: VFY: unable to resolve static method 21535: Lcom/google/android/gms/common/internal/zzx;.zzb (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm: VFY: replacing opcode 0x71 at 0x0002
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
E/dalvikvm: Could not find class 'com.google.android.gms.ads.internal.client.zze', referenced from method com.google.android.gms.ads.internal.client.zzn.<init>
W/dalvikvm: VFY: unable to resolve new-instance 2192 (Lcom/google/android/gms/ads/internal/client/zze;) in Lcom/google/android/gms/ads/internal/client/zzn;
D/dalvikvm: VFY: replacing opcode 0x22 at 0x000a
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
VFY: unable to find class referenced in signature (Lcom/google/android/gms/ads/internal/client/zze;)
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zzaf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zzaf;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zzaf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zzaf;' failed
VFY: unable to find class referenced in signature (Lcom/google/android/gms/ads/internal/client/zzaf;)
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/internal/zzcv; (3038)
Link of class 'Lcom/google/android/gms/internal/zzcv;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/internal/zzcv; (3038)
Link of class 'Lcom/google/android/gms/internal/zzcv;' failed
W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/google/android/gms/internal/zzcv;)
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/reward/client/zzf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/reward/client/zzf;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/reward/client/zzf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/reward/client/zzf;' failed
W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/google/android/gms/ads/internal/reward/client/zzf;)
Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zze; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zze;' failed
D/dalvikvm: DexOpt: unable to opt direct call 0x42de at 0x0c in Lcom/google/android/gms/ads/internal/client/zzn;.<init>
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/client/zzaf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/client/zzaf;' failed
D/dalvikvm: DexOpt: unable to opt direct call 0x427b at 0x1a in Lcom/google/android/gms/ads/internal/client/zzn;.<init>
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/internal/zzcv; (3038)
Link of class 'Lcom/google/android/gms/internal/zzcv;' failed
D/dalvikvm: DexOpt: unable to opt direct call 0x623a at 0x21 in Lcom/google/android/gms/ads/internal/client/zzn;.<init>
W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/ads/internal/reward/client/zzf; (3038)
Link of class 'Lcom/google/android/gms/ads/internal/reward/client/zzf;' failed
D/dalvikvm: DexOpt: unable to opt direct call 0x46fd at 0x28 in Lcom/google/android/gms/ads/internal/client/zzn;.<init>
W/dalvikvm: DexOpt: resolve class illegal access: Lcom/google/android/gms/ads/internal/util/client/zza; -> Lcom/google/android/gms/common/zze;
I/dalvikvm: Could not find method com.google.android.gms.common.zze.isGooglePlayServicesAvailable, referenced from method com.google.android.gms.ads.internal.util.client.zza.zzU
W/dalvikvm: VFY: unable to resolve static method 22073: Lcom/google/android/gms/common/zze;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
D/dalvikvm: VFY: replacing opcode 0x71 at 0x0000
I/dalvikvm: Could not find method com.google.android.gms.internal.zzne.zzsi, referenced from method com.google.android.gms.ads.internal.util.client.zza.zzW
W/dalvikvm: VFY: unable to resolve static method 27575: Lcom/google/android/gms/internal/zzne;.zzsi ()Z
D/dalvikvm: VFY: replacing opcode 0x71 at 0x0014
W/dalvikvm: Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/android/gms/ads/internal/client/zzn;
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/android/gms/ads/internal/client/zzaa;
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/android/gms/ads/AdRequest;
D/AndroidRuntime: Shutting down VM
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x417e1da0)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 29691
java.lang.NoClassDefFoundError: com.google.android.gms.ads.internal.client.zze
at com.google.android.gms.ads.internal.client.zzn.<init>(Unknown Source)
at com.google.android.gms.ads.internal.client.zzn.<clinit>(Unknown Source)
at com.google.android.gms.ads.internal.client.zzaa.<clinit>(Unknown Source)
at com.google.android.gms.ads.AdRequest.<clinit>(Unknown Source)
at com.google.android.gms.ads.AdRequest$Builder.<init>(Unknown Source)
at com.xxx.xxx.MainActivity.requestNewInterstitial(MainActivity.java:77)
at com.xxx.xxx.MainActivity.onCreate(MainActivity.java:49)
at android.app.Activity.performCreate(Activity.java:5541)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2368)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2464)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Disconnected from the target VM, address: 'localhost:8602', transport: 'socket'
my gradle info also i run android version 3.2 and gradle wrapper gradle-4.6
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "KING-DEV"
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
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.2.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
}
apply plugin: 'com.google.gms.google-services'**
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Try applying plugin of google play services
apply plugin: 'com.google.gms.google-services'
To solve this, please change the following line of code:
compile 'com.google.android.gms:play-services-ads:8.4.0'
to
implementation 'com.google.android.gms:play-services-ads:16.0.0'
And remove ** after this line of code:
apply plugin: 'com.google.gms.google-services'

Verifier rejected class on API 16

I get following exception log if I try to open my app on API 16 (on API 27 it is working):
V/FA: onActivityCreated
I/dalvikvm: Could not find method android.app.AlarmManager.setExactAndAllowWhileIdle, referenced from method com.text.app.utilities.COLNotification.addPreAlarm
VFY: unable to resolve virtual method 130: Landroid/app/AlarmManager;.setExactAndAllowWhileIdle (IJLandroid/app/PendingIntent;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0021
I/dalvikvm: Could not find method android.app.AlarmManager.setExact, referenced from method com.text.app.utilities.COLNotification.addPreAlarm
W/dalvikvm: VFY: unable to resolve virtual method 129: Landroid/app/AlarmManager;.setExact (IJLandroid/app/PendingIntent;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0084
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
I/dalvikvm: Could not find method android.app.NotificationChannel.getSound, referenced from method com.text.app.utilities.COLNotification.buildNotification
W/dalvikvm: VFY: unable to resolve virtual method 264: Landroid/app/NotificationChannel;.getSound ()Landroid/net/Uri;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0131
W/dalvikvm: VFY: unable to resolve exception class 435 (Landroid/os/FileUriExposedException;)
W/dalvikvm: VFY: unable to find exception handler at addr 0x25e
W/dalvikvm: VFY: rejected Lcom/text/app/utilities/COLNotification;.buildNotification (Lcom/text/app/models/appModel;)V
W/dalvikvm: VFY: rejecting opcode 0x0d at 0x025e
W/dalvikvm: VFY: rejected Lcom/text/app/utilities/COLNotification;.buildNotification (Lcom/text/app/models/appModel;)V
W/dalvikvm: Verifier rejected class Lcom/text/app/utilities/COLNotification;
All warnings are correct because the methods like "NotificationChannel" are not existing in API 16.
And the code I use for example the "NotificationChannel" is not executed because I check for the Build.VERSION.SDK.INT!
What exactly is the problem? Can anybody help?
I used the "FileUriException" in a catch statement and this caused the the problem.
Instead of:
catch(FileUriException e) {
}
I do now:
catch(Exception e) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && e instanceof FileUriExposedException) {
}
}

Android studio build and run App with over limit GC size for methods

I got below things in logcat when running my application, I stuck with this and not able to solve this issue any more, I Google it but and for supporting more than 65k method use Android studio I do it but unfortunately can help that too.
Error
04-16 18:07:28.442 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3181 (com_facebook_loginview_text_color) in Lcom/facebook/android/R$color;
04-16 18:07:28.442 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0025
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3265 (com_facebook_login_view) in Lcom/facebook/android/R$styleable;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x62 at 0x0005
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3248 (com_facebook_loginview_log_out_button) in Lcom/facebook/android/R$string;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x001a
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3246 (com_facebook_loginview_log_in_button) in Lcom/facebook/android/R$string;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x002f
04-16 18:07:28.452 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c76 at 0x32 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.452 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c6c at 0x4a in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c7c at 0x64 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c7e at 0x69 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c71 at 0x72 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c73 at 0x7f in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c75 at 0x89 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c74 at 0x93 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c72 at 0x9d in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc2 at 0x0b in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc3 at 0x13 in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc4 at 0x1b in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc5 at 0x23 in Lcom/facebook/widget/LoginButton;.parseAttributes
To build apps with more than 65k methods you must add multi dex support.
Add these to your app gradle file.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14 // Multi Dex not supported below 14
targetSdkVersion 23
multiDexEnabled true // To Enable Multi Dex
}
dexOptions {
preDexLibraries = false /*Include these three statements to build app quickly (at least faster than before :p) */
javaMaxHeapSize "4g" // To avoid GC Limit Exception
jumboMode = true // To avoid GC Limit Exception
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
/* MultiDex - method count exceeds 65k */
compile 'com.android.support:multidex:1.0.1'
}
Now make an Application Singleton Class and Override attachBaseContext()
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Don't forget to declare it in your Manifest
<application
android:name=".AppController" <!-- Your Application Singleton Class Name -->
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
...
...
</application>
Due to memory limitations in android studio you still might get GC Error.
Try cleaning you project and then building it again.
You're all set now!

NoClassDefFoundError for .jar library at runtime in Android Studio

Hi Friends at Stack Overflow
I recently run into a problem when implementing Fiksu SDK in my Android app. A brief intro, Fiksu SDK is a marketing tool to register installation and events. All the methods related to Fiksu is in a .jar file called "ASOTracking.jar"
The problem:
The library is setup correctly, there is no error reported by Gradle when project compiles and I can even make debug apk. However, it throws "java.lang.NoClassDefFoundError" at runtime when it tries to initialize the SDK.
The log:
01-27 14:06:54.801 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.getClientId
01-27 14:06:54.801 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.801 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuConfigurationManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.initialize
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13733: Lcom/fiksu/asotracking/FiksuConfigurationManager;.getInstance ()Lcom/fiksu/asotracking/FiksuConfigurationManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000f
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.isAppTrackingEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setAppTrackingEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuDeviceSettingsManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setClientId
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13738: Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;.getInstance ()Lcom/fiksu/asotracking/FiksuDeviceSettingsManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp I/dalvikvm﹕ Could not find method com.fiksu.asotracking.FiksuConfigurationManager.getInstance, referenced from method com.fiksu.asotracking.FiksuTrackingManager.setDebugModeEnabled
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve static method 13733: Lcom/fiksu/asotracking/FiksuConfigurationManager;.getInstance ()Lcom/fiksu/asotracking/FiksuConfigurationManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0001
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.CustomEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadCustomEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2112 (Lcom/fiksu/asotracking/CustomEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x000f
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.PurchaseEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadPurchase
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2125 (Lcom/fiksu/asotracking/PurchaseEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0022
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.PurchaseEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadPurchaseEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2125 (Lcom/fiksu/asotracking/PurchaseEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0014
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.RegistrationEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadRegistration
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2126 (Lcom/fiksu/asotracking/RegistrationEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x001e
01-27 14:06:54.806 31166-31166/com.example.myapp E/dalvikvm﹕ Could not find class 'com.fiksu.asotracking.RegistrationEventTracker', referenced from method com.fiksu.asotracking.FiksuTrackingManager.uploadRegistrationEvent
01-27 14:06:54.806 31166-31166/com.example.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 2126 (Lcom/fiksu/asotracking/RegistrationEventTracker;) in Lcom/fiksu/asotracking/FiksuTrackingManager;
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0010
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35ce at 0x2b in Lcom/fiksu/asotracking/FiksuTrackingManager;.initialize
01-27 14:06:54.806 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35c5 at 0x2e in Lcom/fiksu/asotracking/FiksuTrackingManager;.initialize
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x359b at 0x15 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadCustomEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35cf at 0x30 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadPurchase
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35cf at 0x23 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadPurchaseEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35d1 at 0x26 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistration
01-27 14:06:54.811 31166-31166/com.example.myapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x1507 at 0x16 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistrationEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/dalvikvm﹕ DexOpt: unable to opt direct call 0x35d1 at 0x19 in Lcom/fiksu/asotracking/FiksuTrackingManager;.uploadRegistrationEvent
01-27 14:06:54.811 31166-31166/com.example.myapp D/AndroidRuntime﹕ Shutting down VM
01-27 14:06:54.811 31166-31166/com.example.myapp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41ecb700)
01-27 14:06:54.821 31166-31166/com.example.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.fiksu.asotracking.FiksuConfigurationManager
at com.fiksu.asotracking.FiksuTrackingManager.initialize(FiksuTrackingManager.java:83)
at com.example.userinterface.MyApplication.onCreate(MyApplication.java:56)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4684)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
My local environment:
Project is developed on Android Studio
I'm using Mac OS X 10.8.5 Mountain Lion
compileSdkVersion 21, buildToolsVersion "21.1.2",
gradleVersion = '2.2.1', com.android.tools.build:gradle:1.0.0
This is a multi-module project. Application module calls "userInterface" library module and this SDK lies in this library module.
What I've tried:
I do make sure the SDK (jar) file is properly setup and there is no compile error reported by Gradle
I make sure there is no syntax error at the places where SDK methods is called
I checked the dependency of the module that calls this SDK to make sure there is no dependency problem. I go so far that I even trim the whole dependency tree (I know it's unnecessary).
I tried deleting the "build" directory of all modules and rebuild the whole project
I performed the "Invalidate Cache/Restart" operation in Android Studio
I performed "./gradlew clean" command via Terminal at both root directory and application module directory.
I consulted the following links in STO with no success:
Android Studio - Importing external Library/Jar
Android Studio: Add jar as library?
Android studio Gradle Could not find method compile()
Getting "Caused by: java.lang.VerifyError:"
Unable to find classes in Android library file
NoClassDefFoundError with libraries in Android Studio
Final thoughts:
I need some serious help because I've tried everything I know. This SDK worked fine before I migrated this project from Eclipse. Now it throws weird exception when running in Android Studio.
There is one last thing that's kinda suspicious --- the classpath file in Android Studio (the ***.imi file), I re-arrange the classpath entries in it and it still doesn't work.
Thank you guys advance for your help!
New Findings
My GS4 (Android 4.3) cannot run this app, but HTC One M8 (Android 5.0.1) can run it
Root Cause
65K methods limit
Refer to this document: https://developer.android.com/tools/building/multidex.html
Basically there is a methods reference limit and the only solution is to use multidex configuration. However there are implementation for platforms prior 5.0 and after 5.0
Solution
The solution is described in both:
https://developer.android.com/tools/building/multidex.html
https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html
For my project, since it supports older version of Android, I go with the "multidex support library" solution.
Set the build tool version of all library modules and app module to the latest 21.1.2
For module that has Application class, add compile 'com.android.support:multidex:1.0.0' as dependency
Refer to this link to modify your application class. https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html
At the same gradle script, under android -> defaultConfig block, add "multiDexEnabled true"
If your system gives "Java Heap Size" error, in the app module's gradle script, add the following
dexOptions {
incremental true
javaMaxHeapSize "4g"
}

Could not find class 'com.google.android.maps.GeoPoint', referenced from method

I have one user running my app getting the following error, which I can't reproduce on my phone or I haven't see on any other phone.
Can any one suggest why this isn't working just for this user, they say that the Googlemaps app works fine.
Note I have Google API and maps in my manifest too.
E/dalvikvm( 1978): Could not find class 'com.google.android.maps.GeoPoint', referenced from method id.wilsononline.gcadroid.gcadroid$loadNearby.<init>
W/dalvikvm( 1978): VFY: unable to resolve new-instance 522 (Lcom/google/android/maps/GeoPoint;) in Lid/wilsononline/gcadroid/gcadroid$loadNearby;
D/dalvikvm( 1978): VFY: replacing opcode 0x22 at 0x006b
D/dalvikvm( 1978): DexOpt: unable to opt direct call 0x0de1 at 0x7d in Lid/wilsononline/gcadroid/gcadroid$loadNearby;.<init>
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
W/dalvikvm( 1978): VFY: unable to find class referenced in signature (Lcom/google/android/maps/GeoPoint;)
I/dalvikvm( 1978): Could not find method com.google.android.maps.GeoPoint.getLatitudeE6, referenced from method id.wilsononline.gcadroid.gaLoadNearbyCaches.startLoadCaches
W/dalvikvm( 1978): VFY: unable to resolve virtual method 3554: Lcom/google/android/maps/GeoPoint;.getLatitudeE6 ()I
D/dalvikvm( 1978): VFY: replacing opcode 0x6e at 0x0004

Categories

Resources