I am locked with Android Studio.
As I was developing my first android app, I sometime pushed the "Run 'app'" button to test and see how the app was working. With no problem up to this point, but then I tried to use Image Asset Studio to make my own icon. And now when I try to use the "Run 'app'" button to test, all I can see is the image below keeping coming back and the app is no longer started. I guess I did something wrong on the way; though I have no idea what. Can anyone think of what I should do to get back on my feet and have the app working again? I haven't changed any part of the code since it was last working.
And hereafter is a second screenshot showing an error:
Running the find command on the project directory, for the file ic_launcher.webp, I get this result.
I suppose some of the files shouldn't be there.
MyMac$ find AndroidStudioProjects/MyApp -name ic_launcher.webp
AndroidStudioProjects/MyApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp
AndroidStudioProjects/MyApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp
AndroidStudioProjects/MyApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
AndroidStudioProjects/MyApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
AndroidStudioProjects/MyApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
MyMac$
But for comparison if I run the same command on the directory for a project where this issue does not appear. I find even more of the ic_launcher.webp file, so I must be missing some detail.
MyMac$ find AndroidStudioProjects/MyOtherApp -name ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/build/intermediates/packaged_res/debug/mipmap-xxxhdpi-v4/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/build/intermediates/packaged_res/debug/mipmap-hdpi-v4/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/build/intermediates/packaged_res/debug/mipmap-xhdpi-v4/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/build/intermediates/packaged_res/debug/mipmap-mdpi-v4/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/build/intermediates/packaged_res/debug/mipmap-xxhdpi-v4/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
AndroidStudioProjects/MyOtherApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
MyMac$
Related
I created a simple method in the MainActivity named test()`, and then later I removed it 'cause it was not needed anymore. But after running the application again, I get the following error
java.lang.NoSuchMethodError: No virtual method test()Landroidx/lifecycle/LiveData; in class Lcom/shaunyl/navigationtest/user/model/UserViewModel; or its super classes (declaration of 'com.shaunyl.navigationtest.user.model.UserViewModel' appears in /data/data/com.shaunyl.navigationtest/code_cache/.overlay/base.apk/classes4.dex)
at com.shaunyl.navigationtest.MainActivity.onCreate(MainActivity.kt:70)
at line 70 of the file MainActivity there's not such a method of course, because I just removed it. But android studio keeps marking it (like caching it somewhere in the code_cache folder and never taking track of it), preventing the application to start up.
I have tried to delete the .idea folder, invalidate caches and restart android studio, and even restart the emulator. Nothing worked.
Only thing that works is to wipe out emulator's data and restart it again.
But this is not a practical solution. Every time I write and then delete a method, or write and then delete a class, this issue pulls up.
Is there any solution to this annoying problem?
Thanks
Answer based on my original comment above:
As you can see in the error message, the dex file in question with the obsolete reference to the removed method is on the device, not on your build area.
Simply uninstalling and reinstalling the app on the device should help. Or you can use the 'Clear storage' button in the app info view on the device.
I got an app and there is this tiny error about the image name. The name is 'bg.png.png' which was allowed in Eclipse but not in Android Studio. If I fix it, I get 100 errors regarding 'Error retrieving parent for item'.
By the way I am using appcompat7 too. So I don't know how to fix and where this images is called in the code because the code is huge and I am not very good at android.
Select the image and press Shift+F6 (OR Right-click->Refactor->Rename). This will start the refactoring of selected image name. change the name to a valid one while highlghted and hit Enter. It will get renamed in all referenced places. Will prompt for confirmation so you have a chance to cancel if you feel it is not refactoring correctly. But it works just fine so you need not worry.
Is it possible to debug an app on many phones at the same time in Android Studio? By this I mean launching multiple debug instances, each one on a different phone, like in Eclipse.
At the time of posting this question probably the only solution was the one posted by George V.M. Now, after several updates of Android Studio, this can be easily done by creating N copies of the same Debug configuration and launching each of them on a separate phone.
Update
You might want to take a look at Vlad's answer. This one is pointless for newer versions of Android Studio. In case anyone is still curious, this was my really hacky way of solving the problem
In case anyone out there is still looking for a solution to this, here's what I've found.
I'm working on a project that requires wireless communication between 2 instances of the same app running on 2 phones (actually, 2 or more). There were a lot of times where I wished I could debug 2 devices at a time. It wasn't until recently that I figured out how to do it.
It's actually quite simple: Have 2 instances of Android Studio open and you can debug multiple devices at once, (one device on each Android Studio instance) with breakpoints and everything!
Catch 1: You can't open two instances of the same project
I haven't been able to run two instances of Android Studio where both instances have the same project open. It will just redirect you to the already open project.
Solution:
The solution to this is to just make a copy of your project somewhere on your PC and open that project allowing you to have two copies of the same project open.
Catch 2: Changes have to be made on each copy manually.
Now here's a new problem. What if while debugging, you find a mistake in your code and amend it. Now you have to make sure you make that exact same amendment in your second copy of the project so that the second device doesn't have the same error if it hits those lines. This is annoying, having to remember to make a change twice; once in each copy of the project.
Solution:
My solution to this problem was to just make a 'symbolic link' of the project instead of a physical copy.
(A symbolic link is a 'nickname' or a 'reference' to a file. If you make a symbolic link fileB that points to fileA, although they seem like two distinct files to the OS, they in fact point to the exact same physical file. Any changes made on fileA will be reflected in fileB since they point to the same physical file/data on the disk. Instructions on how to create symbolic links are given below)
Now hold on just one second!!! Making a symbolic link of the entire project might not be a very smart idea since you'll have two Android Studios trying to edit the same files. This could lead to problems, especially in the case of build files and IDE files.
So what I did was make a symbolic link of only the source files, or any file which I'd be editing directly and which AS wouldn't normally touch, and make a physical copy of every other file.
The only thing you need to do is remember to hit Ctrl+S after making changes to your code in one AS instance so that the changes will be reflected on the second one. It might still take a couple of seconds for those changes to be reflected in the second instance but you can just click the "Synchronize" button (top left, next to "Open" and "Save") on your second AS which will cause all externally changed files, i.e., the file you just edited in your first instance, to be reloaded from disk.
You still need to be careful though. Every time you make a change in one AS, make sure you save all those changes and that those changes are reflected in the second AS before you try doing any editing in the second AS. Otherwise conflicts could cause you to lose the changes you made in one copy. One way around this is to force yourself to make changes to a file only on one AS and not the other.
Actual Instructions:
Okay that was a lot of talk. Here are the steps you can follow along with tips:
Close Android Studio and make a copy of your project into another folder on your PC
Go to your second copy and delete all your source code files since we're going to make symbolic links of them.
(these are the files I usually make symbolic links of instead of a copy:
all build.gradle files
the entire app/src folder
if you have any other loose source or resource files or othwerwise non IDE files that you might edit, make symbolic links of them as well
Make a symbolic link of all those non IDE files from the first project folder into your second project folder.
to make a symbolic link of a file in Windows, use
mklink path\to\symbolic\link path\to\original\file
to make symbolic link of a folder in Windows, use
mklink /j "path\to\symbolic\link" "path\to\original\folder"
to make a symbolic link of a file or folder in Linux, use
ln -s "path/to/original/file_or_folder" "path/to/link"
Open up Android Studio again. It will probably open the original copy of your project if that was the last project you opened in AS.
Go to File>Open and open up the second project copy on your PC.
You will now have 2 copies of your project running and you will be able to debug your app on 2 devices at the same time! (Remember that breakpoints won't be shared between the two copies)
If you are talking about attaching the debugger to several phones, I'm going to say no.
The port will be blocked with that traffic from one phone.
Unless someone figure out a hacky way to do this, atm It's not possible as far as my knowledge.
Android studio has its VM devices, but it requires installing Intel Accelerator because it's too slow until it show up. alternatively, I recommended "Genymotion" for running multiple instances and different devices. I'm using it and its working perfectly.
It may takes a while for setup and installing but once its installed it will be light weight and I promise you'll be pleased while working on it =)
Here is the link:
genymotion intallation user guide,
genymotion website
I' m trying to modify the application's graphic. So when I decompile the apk using apktool with apktool d myapp.apkeverything goes well. I can see the resources and the smali folders so it's perfect. So I can modify the colour code that I need to change.
When I try to build back the application using apktool b myapkfolder no errors are displayed from apktool. But when I try to install it on my phone it says "Parse error there has been a problem for analysing the packet". So I though it use my fault modifying something wrong in the application so I tried to decompile the apk and then recompile it without touching anything in the apk folder. What I can see is that the original apk size is 5.78MB and the recompiled one is 5.77MB (and I didn't touch anything literally) and when I try to install it, the phone gives me back the same error "Parse error there has been a problem for analysing the packet".
So I can't figure out what the problem is. I thought the problem was related to code obfuscation but I' m note sure. Is there a solution for that?
Well If you have lost you project and you want to import it to eclipse then you can use this link: click here
And Yes ill tell you your question is valid ( and by the way there's nothing to do legal or illegal here as this forum is to clear your doubts )
The link will have two parts on importing your decompiled files and yes if you are unsuccessful in decompiling then this link will help you out click here
And yes you try these things anywhere..( and personally you MUST KEEP A BACKUP ON CLOUD STORAGE , WHERE YOU CAN ACCESS IT FROM ANYWHERE )
Until recently I could double-click a line in stack-trace the logcat and it would open the source at that point.
Suddenly it has stopped working.
Is it possible that I accidentley changed some option somewhere?
What could I have done wrong?
I found it.
In the project Properties->Java Build Path->Order and Export the src folder of the library had to be selected. For some reason it wasn't.
Works great now.
Well, I don't know about the option, but I can tell you that I've experienced that (and other) particularity with logcat without touching anything in the configs. What I do is make sure that log output is not paused (the little "||" button in logcat console) and if it is I unapuse it in order to let me double click on an entry and have it highlight the corresponding code. Also you may try adding then removing some filters in order to force it come back to life. I know it's lame but from what I've seen it has such issues.
There is a method in this link that creates a log that opens your log position when you click on the row in logcat.
Enjoy!
I had this happen when I cloned a new project from an old project and then ran the new project. Apparently Eclipsed was confused by there being two files with the same path and name in two different open projects in the same workspace. When I closed the old project, it return to switching perspectives and taking me to the line of code when I double clicked the line in logcat.