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
Related
I have the following error when I try to run my React Native app in Android Studio.
When running the application, it tries to start, but fails and displays the following error.
07/26 15:05:47: Launching 'app' on Pixel 3 API R.
$ adb shell am start -n "com.recetasdemiyaya/com.recetasdemiyaya.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 6259 on device 'Pixel_3_API_R [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/recetasdemiyay: Not late-enabling -Xcheck:jni (already on)
I/recetasdemiyay: Unquickening 13 vdex files!
W/recetasdemiyay: Unexpected CPU variant for X86 using defaults: x86
I/recetasdemiyay: The ClassLoaderContext is a special shared library.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
No Network Security Config specified, using platform default
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.recetasdemiyaya, PID: 6259
java.lang.RuntimeException: Unable to instantiate application com.recetasdemiyaya.MainApplication: java.lang.ClassNotFoundException: Didn't find class "com.recetasdemiyaya.MainApplication" on path: DexPathList[[zip file "/data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/base.apk"],nativeLibraryDirectories=[/data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/lib/x86, /data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/base.apk!/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1211)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6521)
at android.app.ActivityThread.access$1300(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1885)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7464)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.recetasdemiyaya.MainApplication" on path: DexPathList[[zip file "/data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/base.apk"],nativeLibraryDirectories=[/data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/lib/x86, /data/app/~~CE-MOv3Jm55BXMcdUPlUeg==/com.recetasdemiyaya-889WixNrp2DNabkeMOGRLA==/base.apk!/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:202)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:49)
at android.app.Instrumentation.newApplication(Instrumentation.java:1158)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1203)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6521)
at android.app.ActivityThread.access$1300(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1885)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7464)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
In the EVENT LOG section, it shows me the following error:
Unsupported Modules Detected: Compilation is not supported for
following modules: lottie-react-native, react-native-admob,
android-react-native-fbsdk, android-react-native-onesignal,
android-react-native-fast-image, android-react-native-blur,
android-react-native-webview, android-react-native-vector-icons,
android-react-native-gesture-handler,
android-react-native-linear-gradient, android-react-native-admob,
android-lottie-react-native, react-native-blur, react-native-fbsdk,
react-native-onesignal, react-native-gesture-handler,
react-native-vector-icons, react-native-linear-gradient,
react-native-fast-image, react-native-webview. Unfortunately you can't
have non-Gradle Java modules and Android-Gradle modules in one project
.
When I try to run the application in the terminal from the root of my project, with the react-native run-android command, the application shows for an instant, but it doesn't start working, but it doesn't show me errors.
However, when I run the react-native run-ios command the application works perfectly in my simulator.
My experience is little and my command of English is also little, so I do not know where to go and where to look within my project to correct the errors that Android Studio shows me.
I have updated Android Studio, as I have read similar problems before coming to ask, but I don't know how to eliminate LA CACHES / RESTART => INVALIDATE CACHES & RESTART, which I have seen in another question
What should I do for Invalidate Caches?
I'm still looking for a solution, but I can't find a way, I keep looking at other questions, but I think I'm not looking correctly, and that's why I'm here.
Can you help me ?
Thank you
1- close the project
2- close Android Studio IDE
3- delete the .idea directory
4- delete all .iml files
5- open Android Studio IDE and import the project
if issue still exist copy project to other location and open it again in Android studio.
Cleaning gradlew works for me
cd android && ./gradlew clean && cd ..
I did a build on an android with Android Studio, everything was fine, but at some point everything broke down - and an error began to take off on absolutely all devices - I try 3 devices. Application crash on start! I did not change the build.grandle and also did not touch the code associated with it.
Perhaps this is due to the update of some libraries on the server or something?
AppCompatDelegate: Failed to instantiate custom view inflater android.support.v7.app.AppCompatViewInflater. Falling back to default.
java.lang.ClassNotFoundException: android.support.v7.app.AppCompatViewInflater
Invalidate caches and restart in Android Studio
Clean and rebuild project
Remove .grandle path and app/build path and restart android studio
AppCompatDelegate: Failed to instantiate custom view inflater android.support.v7.app.AppCompatViewInflater. Falling back to default.
java.lang.ClassNotFoundException: android.support.v7.app.AppCompatViewInflater
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatViewInflater" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/data/app/com.google.android.gms- gDUN2dwT1uff5iEdzncEiQ==/base.apk"],nativeLibraryDirectories= [/data/app/com.google.android.gms-gDUN2dwT1uff5iEdzncEiQ==/lib/arm64, /data/app/com.google.android.gms- gDUN2dwT1uff5iEdzncEiQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
:Full logcat error
I want do working build without crash
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)
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...
For the purpose of developing an Anti-malware on Android, I need to have the smali representation of an APK.
I'm trying to execute the the baksmali.jar directly on the device. I asked the author of the tool GitHub: Executing baksmali on an Android device.
I followed the steps according to the post
Stack overflow: How to execute the dex file in android with command?
I downloaded the v2.2b4 version
dx --dex --output=classes.dex baksmali.jar I used the dx tool from android/Sdk/build-tools/25.0.2
zip baksmali.zip classes.dex
adb push baksmali.zip /sdcard/ I'm using a genymotion emulator custom phone-4.4.4 API 19
adb shell mkdir /sdcard/dalvik-cache
adb shell ANDROID_DATA=/sdcard dalvikvm -cp /sdcard/baksmali.zip org.jf.baksmali.Main
After that, I'm getting this error message Unable to locate class 'org/jf/baksmali/Main'
Precisely
Unable to locate class 'org/jf/baksmali/Main'
java.lang.NoClassDefFoundError: org/jf/baksmali/Main
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jf.baksmali.Main" on path: DexPathList[[zip file "/sdcard/baksmali.zip"],nativeLibraryDirectories=[/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
... 1 more
Suppressed: java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:296)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:263)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:230)
at dalvik.system.DexPathList.<init>(DexPathList.java:112)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38)
at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:116)
at java.lang.ClassLoader.access$000(ClassLoader.java:65)
at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:125)
... 1 more
I don't understand this error, the classe path is correct.
How can I fix this ?
Thank you in advance.
After moving around, I finally found the solution to the following problem:
" execute the baksmali.jar in an android device, ideally the execution is launched by an application targeting another application."
So, lets say we wont to develop an application that is able to "baksmali" (disassemble) another application, without requiring any special permission.
These are the steps to get the job done:
download the baksmali.jar v1.2.3
add the jar to the app/libs directory of the android studio project
right click on the jar and select the option "Add it as a Library"
(use the "Project->project" view to see the libs directory, you may not see it in the "Project->android" view)
you can use the org.jf.baksmali.main.mainmethode by passing the CLIarguments to that method using a String[]
Here is a helloWorld App illustrating the use cas:
GitHub: Baksmali Hello world
After launchig the application you should see folders in the /data/data/com.example.bartman.baksmalihelloworld/<name_of_baksmali_output>