INSTALL_FAILED_DEXOPT/UID_CHANGED error when trying to install application - java

I tried everything and nothing helps me :(
At first I got:
INSTALL_FAILED_DEXOPT error when trying to install application
Please check logcat output for more details.
Launch canceled!
And then the first error changed to
Installation error: INSTALL_FAILED_UID_CHANGED
I am running the app on Genymotion, so I don't have root and can't delete /data. I restarted eclipse and Genymotion (and tried different emulators in vein). I cleaned my project many times. I uninstalled every app from Settings/Apps, and cleared the app from Storage/misc. I can't factory reset Genemotion. The installation fails on my device (Galaxy 4). I also changed my package name, with no help.
My logcat shows:
cutils-trace(1311): Error opening trace file: No such file or directory (2)
memtrack(1311): Couldn't load memtrack module (No such file or directory)
android.os.Debug(1311): failed to load memtrack module: -2
I tried to revert the code to a known working GIT version, with no help - still installation error: INSTALL_FAILED_DEXOPT. Also - I can't open ab eclipse emulator.
What can I do?

I don't know how, but somehow eclipse was having problem with my package. When I turned 'x_y_z' to 'test', it worked. So weird that it happened out of the blue (I had 'x_y_z' for more than 7 months...).

This usually happens during development when some files don't get removed while installing the new apk over the existing one. If you check the LogCat, you would be able to find exactly which resource was left behind. This is mostly caused by using two different PCs to test on the same device, or also sometimes using a single PC and a BROKEN_PIPE_ERROR while trying to install over an existing version.
Since, some files corresponding to your package stay behind, an application with the same package cannot be installed, until and unless those files are removed forcefully (for which you would need root access).
Or, you could factory reset the device.
If you can't factory reset or don't have root access, you would need to change the package name of the application. Because then, it tricks the OS to believe that it is a separate application, which is why it worked in your case.

Related

Android Studio - The process cannot access the file because it is being used by another process [duplicate]

I can import a sample app project, try to build it and I keep getting this error. Not always the same file but a new temp file each time. I've tried several different samples. I've been programming for 30+ years and feel completely clueless. Only clue seems to be the Windows Task Manager shows 99% to 100% CPU usage when it gives the error and ends the build.
Do This
File -> Invalidate Caches / Restart.. -> Invalidate/ Restart
When this happens to me on Windows 8, I open the task manager
and simply kill all the instances of "openjdk platform binary"
Just clean the project and have a run ! It would work ....
Choose app instead of DefaultPreview. Now if you build, then you should not see this issue.
Invalidating the IDE cache is NOT enough.
To delete the folder app\build we should first stop locking process - OpenJDK Platform binary.
Delete the folder app\build
Invalidate Caches / Restart...
Context: Using Coroutines in Android Instrumented Test.
GL
I have the same issue's.Even I tried all the solution mentioned here it didn't work.Even I can't delete the signin file as running android studio administrative mode.I see a notification at bottom right side of the IDE update gradle pluggin.So update gradle pluggin usually worked for me
Kill task "openjdk platform binary" works for me
Restart of Android Studio with cache invalidation doesn't help.
As others said, we should delete a <module>\build folder. Because a file is locked by OpenJDK Platform binary, we should stop this process in Task Manager (or unlock the file via LockHinter).
I had the same problem and in my case it is due to multiple Java Run times (JRE's). Try switching between JRE's in android studio or use only one Java runtime.
Hope it fix the problem. Happy Coding..
Invalidate Caches / Restart doesn't work all the time and it's not the better idea to close the whole Android Studio just we couldn't figure out what process was using it.
Please follow the below steps to figure out which process is using your file.
You can use the Resource Monitor for this which comes built-in with Windows 7, 8, and 10.
Open Resource Monitor, which can be found
By searching for Resource Monitor or resmon.exe in the start menu, or
As a button on the Performance tab in your Task Manager
Go to the CPU tab
Use the search field in the Associated Handles section
When you've found the handle, you can identify the process by looking at the Image and/or PID column.
You can then try to close the application as you normally would, or, if that's not possible, just right-click the handle and kill the process directly from there.
Ref : https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows
try to delete the file (the folder inside builder message)
the message will contain process name ( i dont remember the name)
find the prcess in task manager and stop it
I had 2 jre's installed when I installed android studio. Uninstall the one that you find from control panel and that is located something like c:\program files\java etc.
On the next opening of android studio 4.0 + it will fallback to "C:\Program Files\Android\Android Studio\jre" and the process lockdown after each succesfull build will stop
If the error is recurring, you can try a file leak detector to determine what part of the gradle process is holding your files. As suggested here,
Download file leak detector
Check with resmon what process is holding on to the file
Depending on where the file is locked, do the following:
Android Studio: In studio, go to Help → Edit custom VM options and add the following line:
-javaagent:path/to/file-leak-detector.jar=http=19999
Gradle: Add to your gradle.properties file the following line:
org.gradle.jvmargs=-javaagent:path/to/file-leak-detector.jar=http=19999
When the problem occurs again, open localhost:19999 in your browser and search for locked files.
In my case, I found out that a file was held by AspectJ compiler/weaver (ajc):
#115 C:\Users\me\StudioProjects\myapp\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar by thread:Execution worker for ':' Thread 3 on Mon Oct 19 18:41:06 BST 2020
at java.util.zip.ZipFile.<init>(ZipFile.java:156)
...
at org.aspectj.tools.ajc.Main$run.call(Unknown Source)
I was running it directly from Gradle:
new Main().run(args, handler)
I don't know if it's possible to make ajc release the files. So I resolved my issue by running it in a separate process. I added a new configuration to get aspectjtools onto classpath:
val weaving: Configuration by configurations.creating
dependencies {
weaving("org.aspectj:aspectjtools:1.9.6")
}
And instead of the above code, I did:
javaexec {
classpath = weaving
main = "org.aspectj.tools.ajc.Main"
args = arguments
}
For those which are still searching for this answer in 2022, remove the build folder and rebuild...
Had the same on Windows 10, it was resolved by closing all "Command Prompt" (cmd) windows 🤷‍♂️
Terminating "OpenJDK platform binary" from Task Manager then deleting src/build and finally rebuilding the project should make it work.
Above suggested solutions may fixed this error but they are time consuming so the best solution to fix this problem is open command prompt and run the following command.
taskkill /im java.exe /f
In my case, deleting the /.gradle/ directory and rebuilding resolved the issue.
If you are using External Emulator:
Restarting Android Studio with cache invalidation doesn't helped.
The file that caused the problem is being used by the emulator and if you are using an external emulator (BlueStacks) like me, restarting Android Studio will not help. I restarted the emulator and the problem went away.
It happened me many times while building or Cleaning the Project
The solution is simple:
Open the Specific Directory
Close the Android Studio
Delete the particular Directory
Now run the Android Studio

org.gradle.tooling.BuildException: invalid code lengths set

I am trying to make dlib-android on Android Studio. It was downloaded from:
https://github.com/tzutalin/dlib-android.
After changing a couple of things such as a mips64... file, it synced and built successfully. But when I try to run with a device or a virtual device, I always get
"Cause: invalid code lengths set" error. The run tasks ended at App:packageDebug. From the long list of things, three under compiler are more informative I guess:
org.gradle.tooling.BuildException: invalid code lengths set
java.util.zip.ZipException: invalid code lengths set
java.lang.IllegalStateException: Still waiting to inspect output APK's res/raw/shape_predictor_68_face_landmarks.dat
On the right side there was: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageDebug'.
I searched all over the places and tried everything I could find, but it did not work. Also, I cleaned the cache and restarted, I tried different emulator and devices. I also tried different project settings and structure settings.
I also noticed that a very similar post was not answered:
build failed because of "org.gradle.tooling.BuildException: invalid code lengths set"
I would like to add that other projects made on the same machine went through fine and ran well on phones or virtual devices.
Or, is it caused by the large res/raw/shape_predictor_68_face_landmarks.dat file that it could not compress?
Or, should I remove the current android studio and install an older version?
Thanks a lot for any suggestion!
I came up with is by downgrading your project level gradle to 3.1.0. It seems to be working on it. The only reason why I think it is causing the problem is latest gradle plugin try to validate every file in your project and somehow it cant read the shape_predictor_68_face_landmarks.dat.
Reference: https://github.com/tzutalin/dlib-android-app/issues/47

Why is Visual Studio trying to use the wrong JDK version?

I am trying to build WeatherApp, which comes from this tutorial, but I am seeing this error:
The specified task executable location "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\javac.exe" is invalid.
and this warning (not sure if they are related):
Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding>
I can doube-click the warning to make it go away, but the error remains. I am not sure why the project is trying to use that version of the jdk, as I have changed my xamarin optioins to point at Program Files instead:
Why is Visual Studio trying to use that versioin of the JDK?
Sometimes there's a sdk.caches file that will hold an old reference. Please try to delete both your obj/bin folders and see if that resolves the issue. If it doesn't, turn up your Build Output verbosity and attach a Build Output Log to your post:
https://forums.xamarin.com/discussion/27515/how-to-obtain-diagnostic-build-logs (XS)
http://blogs.msdn.com/b/msbuild/archive/2005/09/29/475157.aspx (VS)

ClassNotFoundException with static context class [duplicate]

I write a android app in Eclipse and use run command on my cellphone.
It's run success on my cellphone.
But I use [Android Tools -> Export Signed Application Package...] to export my app.
Then use [adb install] to install apk on my cellphone and run.
And I got the error message:
07-22 11:20:43.537: E/AndroidRuntime(20216): Caused by: java.lang.ClassNotFoundException: com.mytest.MyActivity in loader dalvik.system.PathClassLoader[/data/app/com.mytest-1.apk]
In [Java Build Path -> Order and Export], I have been selected all.
In AndroidManifest.xml, the application attribute doesn't have android:name.
I don't know how to solve this problem.
I'm success use Eclipse run on my cellphone, why run error when I export the app?
please help me, thanks!!
I had same issue, after 2 hours of research I managed to fix this problem by deleting "bin" and "gen" folders and rebuilding project.
There seems to multiple reasons for this happening from what I have researched. Do you have a lib folder? if so change it to "libs".
Do you have proguard enabled? If so that may cause the problem.
Also try unchecking the "Android #.#.#" and "Android Dependencies" in your Build Path, Order and Export.
Check out this thread which has a bunch of other possible solutions, a lot of them deal with setting the proper ActivityName in the manifest file.
java.lang.ClassNotFoundException on working app
If those solutions still don't solve the problem try these threads.
Android: Unable to instantiate activity / ClassNotFoundException
ClassNotFoundException Android
What I had to do is just re-do the building/exporting process with no modification to the code whatsoever. It worked for me, which I did was to export it two times.
On my first export, the build APK has lower file size and the second export (with no any modification to the code/configuration) produced a slightly larger file size (about 200KB diff).
This bug in building is really costly, kills you in front of your manager, and should be really fixed by Android/Eclipse team. Kind of sucks

Running Play framework 2.1.1 and getting "exception when typing play.Project.javaCore"

I'm trying out the sample apps that come bundled with the play download and they appear not to be working, but the exception I'm getting isn't clear about what's going on.
I've previously been able to create new applications in Play ok, so this seems a bit odd.
I switched to the samples folder and simply trying running "play":
$ cd ~/play-2.1.1/samples/java/helloworld/
$ play
Which should bring up the play console.
Instead I get this output + exception:
[info] Loading project definition from /home/john/play-2.1.1/samples/java/helloworld/project
exception when typing play.Project.javaCore
class file needed by PlayReloader is missing.
reference type SBTLink of package play.core refers to nonexisting symbol. in file /home/john/play-2.1.1/samples/java/helloworld/project/Build.scala
scala.tools.nsc.symtab.Types$TypeError: class file needed by PlayReloader is missing.
reference type SBTLink of package play.core refers to nonexisting symbol.
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan.toTypeError(UnPickler.scala:66)
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan$LazyTypeRef.complete(UnPickler.scala:79)
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan$LazyTypeRef.load(UnPickler.scala:81)
at scala.tools.nsc.symtab.Symbols$Symbol.typeParams(Symbols.scala:913)
... <rest omitted for brevity> ...
[error] (compile:compile) java.lang.Error
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
It looks like it's not resolving a dependency or something as it's complaining that it's can't find a specific class (SBTLink?)? But really not so sure what's going on here.
Anyone got any ideas on what I'm doing wrong?
UPDATE: actually this appears to be happening for other play projects - so it's not specific to the sample apps.
I've just been able to make a new app ok (using "play new"), but when I switch into it's folder and run "play" I get the same exception as above.
Ok so in the end I had to delete the repository cache - I'm guessing it'd got corrupted somehow. Which would explain why it was complaining about not being able to find some class files.
Another possibility about why it stopped working may be due updates to java itself. There had been at least one update to java (to 1.7.0_25 on ubuntu) since I last tried running play, so there may have been some issue there (perhaps minor binary class file change?).
My play folder is in my home directory, so I did the following:
$ cd ~/play-2.1.1/
$ rm -r repository/cache/
Then tried running play again inside one of the sample app folders. It took a while (presumably as it was rebuilding the cache) and then worked.

Categories