I'm developing and Android App with Android Studio. This app makes use of an all-java library module. I've included jfreesvg by adding compile 'org.jfree:jfreesvg:3.1' to the dependencies of said java library module.
Within that java library, I am trying the given example from the main doc for SVGGraphics2D:
SVGGraphics2D g2 = new SVGGraphics2D(300, 200);
g2.setPaint(Color.black);
g2.draw(new Rectangle(10, 10, 280, 180));
String svgElement = g2.getSVGElement();
However, I get two compile errors in Android Studio, the first being in the second line:
setPaint(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
Also, in the next line, the following error with, I suppose the same cause, occurrs: draw(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
My question now is: Even though java.awt.Paint is an Interface and java.awt.Color is an implementation of that interface, why do I get that error (and the same for java.awt.Shape and java.awt.Rectangle)?
For the sake of completion: If I do run the app, which I'm confused about that it works, I get the following Exception:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: [package].app, PID: 19596
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jfree/graphics2d/svg/SVGGraphics2D;
at [package].[some.package].someMethod(Unknown)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jfree.graphics2d.svg.SVGGraphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at [package].[some.package].someMethod(Unknown)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Graphics2D;
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 11 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Graphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: java.awt.Graphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class "Ljava/awt/Graphics2D;" not found
... 21 more
Suppressed: java.lang.ClassNotFoundException: org.jfree.graphics2d.svg.SVGGraphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class "Lorg/jfree/graphics2d/svg/SVGGraphics2D;" not found
... 14 more
(I edited the stack trace for better readability.)
The java.awt.* package is not available in Android. So the library that you are trying to use cannot be used directly in your Android app. At least not without further work.
You would need to implement those classes yourself, or source them from somewhere else, such as from the Apache Harmony project.
Related
My app keeps force closing in onCreate at the point where I initialise my Firebase.java class.
This is the constructor for the Firebase.java class.
public Firebase(Context context, ProgressChecker progressChecker) {
db = FirebaseFirestore.getInstance();
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setTimestampsInSnapshotsEnabled(true)
.build();
db.setFirestoreSettings(settings);
batch = db.batch();
}
This is the stack trace that I get from Crashlytics.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: julio.ai.moyela.tito.timetoolay, PID: 4740
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at ecb.b(SourceFile:324)
at ece.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ExceptionInInitializerError
at esr.<clinit>(SourceFile:82)
at evl.b(SourceFile:103)
at evm.b(SourceFile:46)
at evm.a(SourceFile:26)
at ese.a(SourceFile:70)
at ebh.<init>(SourceFile:88)
at dwp.a(SourceFile:1217)
at dwr.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at ecb$a.run(SourceFile:190)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getImplementationVersion()' on a null object reference
at etx.b(SourceFile:742)
at etx.<clinit>(SourceFile:197)
at esr.<clinit>(SourceFile:82)
at evl.b(SourceFile:103)
at evm.b(SourceFile:46)
at evm.a(SourceFile:26)
at ese.a(SourceFile:70)
at ebh.<init>(SourceFile:88)
at dwp.a(SourceFile:1217)
at dwr.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at ecb$a.run(SourceFile:190)
at java.lang.Thread.run(Thread.java:761)
I honestly don't know what else to include because this is a Runtime error. It only occurs in my release build, and it stops occurring when I just get rid of the Firestore initialisation.
I am running these firebase libraries as well.
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-invites:16.0.0'
implementation 'com.google.firebase:firebase-firestore:17.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
My app is live on play store. Its not crashing in all devices but I can see this crash in a few device only. Please help me to fix this issue.
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/gms/auth/api/phone/SmsRetriever; at
com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at
com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at
com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at
com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:627)
at
com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at
com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at
com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at
android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at
android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at
android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:148) at
android.app.ActivityThread.main(ActivityThread.java:5417) 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) Caused
by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.auth.api.phone.SmsRetriever" on path:
DexPathList[[zip file
"/data/app/gharkadabba.gharkadabba-1/base.apk"],nativeLibraryDirectories=[/data/app/gharkadabba.gharkadabba-1/lib/x86,
/vendor/lib, /system/lib]] at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at
java.lang.ClassLoader.loadClass(ClassLoader.java:469) at
com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at
com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at
com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at
com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:627)
at
com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at
com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at
com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at
android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at
android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at
android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:148) at
android.app.ActivityThread.main(ActivityThread.java:5417) 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)
Suppressed: java.lang.ClassNotFoundException:
com.google.android.gms.auth.api.phone.SmsRetriever at
java.lang.Class.classForName(Native Method) at
java.lang.BootClassLoader.findClass(ClassLoader.java:781) at
java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at
java.lang.ClassLoader.loadClass(ClassLoader.java:504)
Caused by: java.lang.NoClassDefFoundError: Class not found using
the boot class loader; no stack trace available
I can see Moto G (3rd & 4th Gen), One Plus one device having crash.
I added below line to ProGuard file.
-ignorewarnings
-keep class * { public private *; }
SMS Retriever API is available in Google Play Services v10.2 and is used to auto-verify the OTP SMS.
https://developers.google.com/identity/sms-retriever/
This API will not be available in the devices that do not have Google Play Services installed - like Amazon Fire devices or the devices in the Chinese region.
If you are using this API, you have to check whether Play services are installed in the device before accessing this API.
Looking at your exception, it seems this API has been used by some Facebook kit.
i recently updated Firebase Auth version in my app to 9.8.0 from 9.6.1. However, when I run the app, it crashes instantly. I get following error in the logcat:
java.lang.IllegalAccessError: Interface com.google.android.gms.internal.zzanb implemented by class com.google.firebase.auth.FirebaseAuth is inaccessible (declaration of 'com.google.firebase.auth.FirebaseAuth' appears in /data/data/com.svtech.thirdeye.thirdeye/files/instant-run/dex/slice-com.google.firebase-firebase-auth-9.6.1_65404207295ac58253e1599e984563499e3fff8b-classes.dex)
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
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:1801)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1776)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5427)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4940)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
What is causing this error?? How can I get rid of it???
Disable Instant run on your Android Studio and re-run the app.
To disable Instant Run:
Open the Settings or Preferences dialog.
Navigate to Build,
Execution, Deployment > Instant Run.
Uncheck the box next to Enable Instant Run.
I want to use ProGuard in my project. I activated the option minifyEnabled. When I open the activity that uses the library Retrofit2, the app crashes with:
Unable to create call adapter for interface retrofit2.Call
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gatafan.mydeen/com.gatafan.mydeen.ActivityPlaces}:
java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.ServiceMethod$Builder.b(Unknown Source)
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit$1.invoke(Unknown Source)
at com.gatafan.mydeen.api.$Proxy1.a(Native Method)
at com.gatafan.mydeen.api.VenueManager.requestFoursquare(Unknown Source)
at com.gatafan.mydeen.ActivityPlaces.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
at retrofit2.Utils.e(Unknown Source)
at retrofit2.ExecutorCallAdapterFactory.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
... 21 more
From the github page for Retrofit there is a section explaining what to do when using proguard:
PROGUARD
If you are using Proguard in your project add the following lines to your configuration:
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
try this configuration first, before moving forward with proguard changes
I am trying to make an app that will work on multiple platforms including android. The problem I'm having is that my sun.misc.BASE64Decoder works on the app running on the computer:
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(is);
It's not working on an android device:
E/AndroidRuntime(18172): java.lang.NoClassDefFoundError: Failed resolution of: Lsun/misc/BASE64Decoder;
E/AndroidRuntime(18172): at com.company.app.backend.SomeClass$1.run(SomeClass.java:55)
E/AndroidRuntime(18172): at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(18172): Caused by: java.lang.ClassNotFoundException: Didn't find class "sun.misc.BASE64Decoder" on path: DexPathList[[zip file "/data/app/com.company.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.company.app-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(18172): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(18172): ... 2 more
E/AndroidRuntime(18172): Suppressed: java.lang.ClassNotFoundException: sun.misc.BASE64Decoder
E/AndroidRuntime(18172): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(18172): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(18172): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(18172): ... 3 more
E/AndroidRuntime(18172): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Unfortunately I can not use Java 8's java.util.Base64 because I can't use Java 8. Also I can not use android.util.Base64 since it will not work outside of android.
I will appreciate any help.
If you can use third party libraries, you can use commons-codec.
If not, you can find plenty of pure Java implementations online. Even the Wikipedia article has a code sample. Just add it to your own utility class.