Following the example provided here:
https://developers.google.com/gmail/api/v1/reference/users/messages/send#examples
email.setText() throws a NoClassDefFoundException:
Process: com.slickapp.www.slicklikeapp, PID: 19125
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: javax.activation.DataHandler
at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1428)
at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:1029)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1467)
at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1451)
at com.slickapp.www.slicklikeapp.ComposeEmailActivity$SendEmailTask.doInBackground(ComposeEmailActivity.java:153)
at com.slickapp.www.slicklikeapp.ComposeEmailActivity$SendEmailTask.doInBackground(ComposeEmailActivity.java:113)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Finding solutions in the following links:
java.lang.NoClassDefFoundError: javax.activation.DataHandler
java.lang.NoClassDefFoundError: javax.activation.DataHandler in android
I understand that this exception is due to android not implementing java.awt.datatransfer classes. I tried the solutions but they didnt work. When i added javax.mail 1.5.5 in gradle it shows a duplicate file copied 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/mimetypes.default
File1: C:\Users\Taha\.gradle\caches\modules-2\files-2.1\com.sun.mail\android-activation\1.5.6\34c941857c08ff1d6af9a43a8806342883b2a8e1\android-activation-1.5.6.jar
File2: C:\Users\Taha\.gradle\caches\modules-2\files-2.1\javax.activation\activation\1.1\e6cb541461c2834bdea3eb920f1884d1eb508b50\activation-1.1.jar
I couldnt find any solutions for this. I tried excluding excluding file in gradle packaging options, it didnt work only throwing NoClassDefFound exception again.
Any help would be appreciated.
Related
I am facing this error while building the application
# Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
Please help me whats the wrong
Recently I see an exception in my log that fabric (Beta) tries to check for updates and this is the error:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=
I don't know why fabric tries to check for updates with a null URL, but I really want to remove that error.
Verbose stack trace:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:722)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at java.net.URL.<init>(URL.java:176)
at java.net.URL.<init>(URL.java:125)
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:720)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
I solved a lot of errors logs and the exception above by updating the crashlytics library version.
I also have solved this issue updating Crashlytics version in /app/build.gradle file.
I leave here the code of the fix for convenienece:
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
I'm working on a React Native project that uses djinni to use cross platform native C++.
I already looked at this question, but it seems a different problem.
The project build successfully but fails almost immediately on run.
adb logcat shows the following exception:
No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
I'm trying to understand what tried means in the message above. Is this because the corresponding native code is missing from the apk ? Or maybe another cause ?
Full logcat is following:
04-19 19:44:51.042 2354-2700/com.djinnius E/art: No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
04-19 19:44:51.045 2354-2354/com.djinnius W/unknown:React: Caught exception after cancelling react context init
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.facebook.react.ReactInstanceManager$Result.get()' on a null object reference
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.onCancelled(ReactInstanceManager.java:247)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.onCancelled(ReactInstanceManager.java:197)
at android.os.AsyncTask.finish(AsyncTask.java:665)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
04-19 19:44:51.053 2354-2700/com.djinnius E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
Process: com.djinnius, PID: 2354
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.UnsatisfiedLinkError: No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
at com.djinnius.HelloWorld.create(Native Method)
at com.djinnius.HelloWorld.<init>(HelloWorld.java:27)
at com.djinnius.HelloWorldPackage.createNativeModules(HelloWorldPackage.java:18)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:88)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:950)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:891)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:104)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:218)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:197)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Any help appreciated.
Found the problem.
It was indeed a missing System.LoadLibrary() Call in the Java Class extending ReactPackage.
This is working now with this class initializer
public class HelloWorldPackage implements ReactPackage {
static {
System.loadLibrary("native-lib");
}
I'm using Okhttp:3.4.1 . Using this, all the https calls were giving
java.net.protocolexception: expected ':status' header not present.
Some of blogs advised to update Okhttp. When I update from 3.4.1 to 3.10.0, I'm getting
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NoSuchMethodError: No virtual method setCallWebSocket(Lokhttp3/Call;)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.XXXXXX.android-1/split_lib_dependencies_apk.apk:classes85.dex)
at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)
at com.facebook.react.devsupport.InspectorPackagerConnection$Connection.connect(InspectorPackagerConnection.java:243)
at com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:44)
at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:204)
at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:200)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I'm using react-native:0.45.1
React native use okhttp as a dependency, upgrade okhttp may result in some compatibility issue. Currently it's using okhttp 3.6.0 (https://github.com/facebook/react-native/blob/8466db0fd355aea778ff71cfb10c927cfd18a551/ReactAndroid/build.gradle#L288). So my advice is that just leave it be.
I tried to implement an OData V2 Client using Apache Olingo OData 2.0 in Android.
Executing the client class as java class works fine, but I cannot run the Android App using the same code in an AsyncTask:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.my.app.appname, PID: 2521
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.conurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.conurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory;
at org.apache.olingo.odata2.core.commons.XmlHelper.createStreamReader(XmlHelper.java:41)
org.apache.olingo.odata2.core.edm.provider.EdmxProvider.parse(EdmxProvider.java:50)
org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.readMetadata(ProviderFacadeImpl.java:224)
org.apache.olingo.odata2.api.ep.EntityProvider.readMetadata(EntityProvider.java:844)
at connectivity.MyClass.doInBackground(MyClass.java:153)
at connectivity.MyClass.doInBackground(MyClass.java:38)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237) <4 more...>
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList[[zip file "/data/app/com.my.app.appname-2/base.apk"],nativeLibraryDirectories=[/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) <12 more...>
Suppressed: java.lang.ClassNotFoundException: javax.xml.stream.XmlInputFactory
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.findClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
My questions are:
(How) Can I fix this issue?
(I read somewhere that the missing class might not be supported by Android?)
Would it help to switch to Apache Olingo OData 4.0?
(I need to consume an OData V2 service and if Olingo V4 would suport this on Android, I might try to migrate my client...)
Thanks in advance!
You have to repackage the javax.xml.stream classes yourself since Android does not support XML. Olingo V4 has a special android packaged client for that on the V4 dowload page: http://olingo.apache.org/doc/odata4/download.html
Olingo V2 does not have this feature because when the V2 library was created the main focus was on server side implementations. This is why a lot of convenience on client side is missing.