java.lang.NoClassDefFoundError: Failed resolution of: Ldji/common/flightcontroller/CompassCalibrationState - android

I'd like to read different DJI hardware states using the DJI Android SDK. But for some architectures (Intel), certain DJI classes cannot be resolved using the libraries. This leads to java.lang.NoClassDefFoundError
Affected Devices: Lenovo Yoga series, Asus ZenFone series.
On all other devices (that use different native libraries) it works without any issues. Did DJI not properly include these classes in the Intel Architecture libraries?
We declare the dependencies in the app build.gradle as follows:
dependencies {
implementation('com.dji:dji-uxsdk:4.9')
compileOnly('com.dji:dji-sdk-provided:4.9')
}
We would expect the proper resolution of these classes, but get the following errors:
java.lang.NoClassDefFoundError: Failed resolution of: Ldji/common/flightcontroller/CompassCalibrationState
java.lang.NoClassDefFoundError: Failed resolution of: Ldji/common/flightcontroller/imu/SensorState;
Stacktrace:
Caused by java.lang.ClassNotFoundException: Didn't find class "dji.common.flightcontroller.CompassCalibrationState" on path: DexPathList[[zip file "/data/app/com.droneharmony.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/com.droneharmony.planner-1/lib/arm, /data/app/com.droneharmony.planner-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Related

app crashes with MapView if i use sdk 29 ------

I have a problem with MapView. My map was loaded correctly until I used "targetSdkVersion 19", but since I updated to "targetSdkVersion 29" every time I launch the map activity, the app crashes.
Can anyone tell me what the problem might be?
2019-08-29 17:04:05.679 29021-29119/mcsistemi.tentatavendita E/AndroidRuntime: FATAL EXCEPTION: Thread-8
Process: mcsistemi.tentatavendita, PID: 29021
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at ce.b(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3)
at cb.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3)
at cd.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):14)
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):4)
at bf.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):22)
at bf.run(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):8)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/000000c6/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/000000c6/MapsDynamite.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader#19056081#19.0.56 (100400-262933554):4)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at ce.b(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3) 
at cb.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3) 
at cd.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):14) 
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):4) 
at bf.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):22) 
at bf.run(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):8) 
Add this under <application> tag in Manifest.xml
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
With Android 6.0, we removed support for the Apache HTTP client.
Beginning with Android 9, that library is removed from the
bootclasspath and is not available to apps by default.
To continue using the Apache HTTP client, apps that target Android 9
and above can add the above line to their AndroidManifest.xml:
Here is more info
by Google
Since you say it started after android sdk 29, the problem could also be from the fact that you haven't changed your mappings to the current androidx mappings in the layout file that bring up this problem
If there is a library call like android.support.v7.widget.CardView in your layout causing the problem, you must change it to androidx.cardview.widget.CardView in android X and sdk 29 upwards..
For more mappings and how its currently written in the layout files, kindly check this link for the other class mappings https://developer.android.com/jetpack/androidx/migrate/class-mappings

Class not found at run time though it's in apk file

I'm trying to run a program on the phone from android studio. It tries to send an email using javax.mail. When running under the debugger, see these errors in the debug console.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/mail/util/MailLogger;
at javax.mail.Session.initLogger(Session.java:261)
at javax.mail.Session.<init>(Session.java:245)
at javax.mail.Session.getDefaultInstance(Session.java:356)
at com.example.sendemail.GMailSender.<init>(GMailSender.java:53)
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sun.mail.util.MailLogger" on path: DexPathList[...]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at javax.mail.Session.initLogger(Session.java:261) 
...
The class com/sun/mail/util/MailLogger is present in the apk. Found this from 'Analyze APK' (image below). It's in classes.dex. Why isn't it found at run time?
Android Studio version 3.4.1
Android version on phone is 7.0

ClassNotFoundException thrown after Data/Cache cleaning - second run OK

The application I am working on shows a strange symptom - if one cleans data and cache of the application, the application will crash on the first next run with exception, but on the second run it will run without a problem. Does anybody have any idea what could be going on and how to fix it.
What I already did:
deleted all the build dirs and rebuild
disabled instant run
check that the class is in the apk
tired it on multiple phones - all behave the same
Sadly nothing helped...
I am using the latest Android Studio 3.2.1. Compile and target SDK is 28, minimal 21. The app is written in Kotlin. Support lib is 28.0.0 and build tools 28.0.3.
The exception thrown on the first run (the name of the application was changed to protect the innocent):
2018-11-26 18:18:38.780 17135-17135/com.myapp.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.app, PID: 17135
java.lang.RuntimeException: Unable to instantiate service service.ServerNotificationService: java.lang.ClassNotFoundException: Didn't find class "service.ServerNotificationService" on path: DexPathList[[zip file "/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/lib/arm64, /data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3459)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.ClassNotFoundException: Didn't find class "service.ServerNotificationService" on path: DexPathList[[zip file "/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/lib/arm64, /data/app/com.myapp.app-YIEEjJIdfXs58PSDfpg4Ew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3456)
at android.app.ActivityThread.-wrap4(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6710) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) 
So I managed to fix it. It was related to how Android tools merge AndroidManifest.xml files.
Let me explain (for posterity):
The application I am building is composed from a core - which is an android library and the actual application. The class service.ServerNotificationService is part of the library and was declared in AndroidManifest.xml of the said library as:
<service android:name="service.ServerNotificationService" />
Which is correct and the app will run - just not with the clean cache (I still do not understand this part, but I presume it has something to do with the black magic which is Android ART). To fix the problem I changed the line to:
<service android:name="com.myapp.app.core.service.ServerNotificationService" />
Which is the full name for the class. The lesson learned here is always use full class name in the libraries...

TensorFlow + AndroidScanner - couldn't find "libopencv_java3.so"

I'm having a problem with combining Tensorflow and AndroidScanner.
I use Tensorflow to display an overlay over the camera feed. I take a picture with the camera, and then send it to a server. It works.
Now I imported the AndroidScannerDemo, I want to use the taken picture and crop/transform it with the newly imported module. It crashes. When I open the ScanActivity (from the AndroidScannerDemo), it tries to load opencv, and never succeeds. The error message is as follows:
FATAL EXCEPTION: main
Process: fr.pacifica.insurancechat.debug, PID: 2139
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/fr.pacifica.insurancechat.debug-OI_d1EANbiczpZEwAHYdkw==/base.apk"],nativeLibraryDirectories=[/data/app/fr.pacifica.insurancechat.debug-OI_d1EANbiczpZEwAHYdkw==/lib/arm64, /data/app/fr.pacifica.insurancechat.debug-OI_d1EANbiczpZEwAHYdkw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]] couldn't find "libopencv_java3.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
at com.scanlibrary.ScanActivity.(ScanActivity.java:125)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1190)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2837)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
When I delete TensorFlow references from gradle/code, the imported module works just fine.
The project you imported, only builds 32-bit versions of libScanner.so, and therefore only uses the 32-bit versions of libopencv_java3.so. In the short run, you can keep that, only set
android {
defaultConfig {
ndk {
abiFilters 'armeabi-v7a'
}
}
}
This will cause your APK run in 32-bit mode on arm64 devices.
In the long run, you should update the Scanner library to build in 64-bit, too. This may have a significant performance gain.
from August 2019, 64-bit support is required for all apps in Play Store
I had the same problem with some mobiles (64 bits processor)
Here is the libs you need for every single arquitecture. You can download it and import manually.
https://github.com/jhansireddy/AndroidScannerDemo/tree/2cd23d3d362d0a6248cf489a79ebc4ba2c425c60/ScanDemoExample/scanlibrary/src/main/libs

Xamarin.GooglePlayServices.Maps 42.1001.0 SupportMapFragment java.lang.NoClassDefFoundError

I recently updated my Xamarin.Android app to Google Play Services v42.1001.0. Without any other code changes, I noticed that when creating a SupportMapFragment, the output throws the following errors:
Rejecting re-init on previously-failed class java.lang.Class:
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/chimera/Fragment;
Further down the Stack-trace I see this:
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.chimera.Fragment" on path: DexPathList[[zip file
"/data/user_de/0/com.google.android.gms/app_chimera/m/00000006/DynamiteModulesB_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000006/n/armeabi-v7a,
/data/user_de/0/com.google.android.gms/app_chimera/m/00000006/n/armeabi,
/system/lib, /vendor/lib]]
As soon as I comment out the SupportMapFragment code, I no longer see this error.
I have:
Made sure I have the latest SDK and Build tools installed
Cleaned/Rebuilt the solution
Verified that my manifest file targets the proper API versions that are supported by the new Google Play Services libraries as per the release notes
It seems to only be happening with the SupportMapFragment. It's also worth noting that my application does use the Multi-Dex build setting.
What else should I try?

Categories

Resources