I've been having some struggles with building my app after Reinstalling Android Studio. The cues I've gotten have been related to either Java location or installation. With the jre already installed it seems more likely not to be an issue with JAVA.
I've tried importing my project, copy and pasting from .txt files, reinstalling java, redefining java PATH, changing build dependencies, downloading command line sdk manager to build outside of the ide, erasing build caches, and I also let Android Studio rewrite properties.profile when importing Android Studio Project.
Another strange thing, when I create a directory in the project structure it shows up when the ide is initiating before gradle builds. After gradle builds the folder is no longer visible.
EDIT
error: package R does not exist
error: cannot find symbol class appcompat
UPDATE
This seems like a common problem. I've tried to follow most of the current questions on java incompatiblity but still haven't come up with a work around. I downloaded oracle's jdk (unnecessarily) and pointed the studio project at it. Created a shortcut using the jdk java.exe and placed it in Studio core, added java to the PATH which allowed gradlew build in the terminal to initiate but not complete. What are the next steps?
UPDATE
Just in case somebody else stumbles onto this. This post and also this one got me there.
The fix ended up being an import of the .R file. com.example.android.recyclerview.R Hope it can help
This question is NOT ABOUT how to debug the javascript-land of an React-Native app. It is about how to debug native libraries (means: JAVA-Code in this case) in the node_modules-folder.
While it is very easy for me to debug native iOS-parts of RN-Applications with XCode, i stumbled upon various issues with Android Studio...
The main thing is, that the node_modules-Folder is not present after importing the project into Studio, why it is not possible to setup breakpoints to debug thru.
Versions:
Android Studio 2.2.2 (most recent version currently)
react-native 0.38.0 (latest version also)
gradle 1.3.1 (preconfigured from react-native init)
also tried with upgrade to gradle 2.2.2
Android SDKs and -Build Tools from up to Version 23 installed including NDK
How I did it / Steps to reproduce
1. create new react native project:
react-native init debugTest
2. install third party library with native code that you want to debug natively
cd debugTest &&
react-native install react-native-sqlite-storage
3. ensure that everything would work on android side:
launch GenyMotion
launch an AVD
run the application with this command in terminal:
react-native run-android
(this will open up packager and everything else that is needed to transfer the js-bundle).
If one wants to omit this step, it is necessary to start the packager manually:
node node_modules/react-native/local-cli/cli.js start
4. launch Android Studio
with the upcoming starter dialog, choose "Import Project"
select the directory "android" of your project and click on "import"
(these steps are taken from official RN-documentation):
If you want to use Android Studio to work on native code, from the
Welcome screen of Android Studio choose "Import project" and select
the android folder of your app.
5. Android Studio asks to update gradle version from pre-configured 1.3.2 to 2.2.2. I have first denied it for the whole workflow, later on i tried it out (both did not differ significantly for me)
6. One have to deactivate Instant Run due to this issue
7. Click on "Run" or "Debug" in the Toolbar of Android Studio
So far everything works fine. I was able to set a breakpoint in MainApplication.java::onCreate and could step into this method then.
But here are the questions:
The node_modules-Folder isn't present in Android Studio and can't be debugged this way. How to achieve that?
Debugging the onCreate-Method and going further down into the Java-Stack, very offen it happened that the "Sourcecode does not match the byte code".
The debugger was hanging somewhere else in comments of source code but not on exactly that line, which was selected to execute.
Android SDKs:
I have installed all SDKs and build tools and NDK and everything else since version 23:
TL;DR:
How to debug native libraries that are present in node_modules-Folder of an react native application with Android Studio, because they are not visible in AS thus no breakpoint could be passed?
UPDATE
Finally i've found out the root cause. For me it wasn't working due to the fact, that the library i wanted to debug, wasn't shown in Android Studio. But this was a mistake by myself because the library wasn't setup correctly, why gradle wasn't able to take notice of it.
So, this question can be used like a blog post how to do it right (and will be sufficient if the 3rd party library works out of the box with "rnpm-link" or "react-native link") [which wasn't the case here in my example]
Have you done rnpm link or react-native link ? Once you do that, there will be additional modules along with the app module, something like this.
You can look at all the java code in the native module and put breakdpoints , debug etc.
Bam.... i can answer my first of the two questions now by myself. Thx to #agent_hunt, who put me into the right direction...
In this example application the bindings wasn't setup correctly. "rnpm link" and the newer one "react-native link", which is part of "react-native install", didn't worked correctly here for the android-part because it is not implemented in the 3rd-party-library right now, that i've used for this example.
That's why gradle didn't take notice of the library. After setting it up correctly, the folder react-native-sqlite-storage appeared in Android Studio and i was able to pass a breakpoint and to stop the execution there.
Nevertheless, debugging this library works fine, but when i wan't to step into lower/"deeper" methods of android SDK, it still has issues to point to the correct line of code ("Sourcecode does not match the byte code")
I am using this framework for one of my projects and i have problems keeping it up to date. It is a little old, uses ant to build the components and is meant for eclipse. I usually use android studio and use gradle to build from interface(not command line).
The project has a host and plugins that are loaded from a server. The plugins are compiled from the command line cmd from windows using "tools/update.sh workspace" and "ant release" commands.
What i succeded so far:
I manually copyed the files from the host component and succeded without too much stroogle to do an android studio project and build it with no errors. And it succesfully loading the plugins.
On the plugin side I have to projects: for every new plugin i do a special android studio project and after everything is ok I adapt the code and copy it to a special template like eclipse project(i edit it with notepad++ no need for eclipse) and i build it with "ant release". That apk then i move it to server.
You see now that it is a little strange but somehow I made it to work. Problem is I'm always on the edge, I almost make it every time with little hacks to pass the build process. I think it is because i work in a mixed situation. I want to port everything on android studio and gradle. And hopefully build everything from the android studio command line.
The host builds in a jar file and is used in the plugin build.
I will put the new source code on request, till then you can see it in action here
To be more specific, the impassable bug appeared when i used MediaPlayer on the plugin. I had to move the wav files on the host witch is opposed to the framework design. But this is anyway the tip of the iceberg. So i would like to port everything from ant to gradle, and eclipse to android studio.
Thanks for your help.
If you have any existing project open in your Android Studio then just close that project. After your project is closed, it will show you a Welcome screen popup, there you can select Import Project option and it will automatically convert your project into Android Studio Project.
Here is what it will look like
I'm working on a Ionic Application and there are a few bugs on Custom Java Plugin imported to the app.
I'm not a Java developer but I wish to understand what happen in those plugins while I run the Ionic Application.
Looking on Google I found a few things like adb logcat that is something terrible and impossible to read.
I tried creating a few messages in the Java Plugin in this way:
Log.d("MyMessage", "Something is happening");
And using grep in the adb logcat to see only my messages but unfortunately it is not enough even because I can not pass a variable as message... so I don't exactly know what is going on in the Plugin while using the app.
I know about JDB but I don't know how to run it together with the Ionic App.
Basically I just wish to create breakpoints or to print dynamic variables while the Plugin is executed to understand where are bugs but I can not find anything useful.
I'm a Javascript developer and I have several tools to debug my Front-End stuff so I think it is quite weird it doesn't exist a way to debug much more complex, back-end, code...
I hope you can help me to do that.
For those still looking for a solution:
You can debug java plugins with Android studio and an Android emulator.
Step 1:
Install Android studio and SDK tools.
Step 2: Get a virtual device running. In order to use the emulator you need to have the Intel x86 emulator accelerator installed. I personally had issues here, I had to disable Hyper-V before it would run. This and other solutions can be found here: The intel x86 emulator accelerator (HAXM installer) revision 6.0.5 is showing not compatible with windows.
Step 3: Do a build for Android in your Ionic project (if you haven't already done so)
Step 4: Navigate to
File > New > Import Project and then navigate to your Ionic project. Don't import the entire project, just the Android folder ( {ProjectName} > platforms > android)
*WARNING: Don't update the gradle if you are presented with the option to do so. This may break the ability to build Android from within the Ionic folder. *
Not updating the gradle may result in a "Gradle project sync failed" error. In my case the solution was to run File -> Invalidate caches / Restart
And that's pretty much it. Once the project is loaded you can use the project tab to navigate to the plugin you want to debug, place breakpoints where you want them, and run debug.
Conversion to Dalvik format failed: Unable to execute dex:
wrapper was not properly loaded first
[project]
Android Packaging Problem
I've never worked with Java or eclipse before, I'm following this introductory guide and all searches via google return no helpful results. I'm guessing the problem is I have built Android stuff with eclipse properly but I have no idea, I followed this guide to the letter and everything went as it explains it should.
Any ideas what caused this problem, or is it specific to the guide? If so I'll post on their help page.
I have tried doing project -> source -> clean up, but that didn't fix anything.
Edit:
I went to Project -> Android tools -> Dex bytecode and it reported:
DexDump: missing classex.dex for project. Please compile first.
So I guess that's my problem! Not sure how to solve though.
Go to Project -> Clean
It will rebuilt workspace and fix the errors if any.
As I said, I had the same problem so I tried all the different versions and
then I stopped filling in the SDK-version number
and finally it did not complain anymore about the wrapper.
After that it was totally fine to write the SDK-version when I created new projects.
Hope it works out for you too.
Had the same problem (running on Windows 7). I resolved it by running Eclipse with Administrator privileges.
try to run eclipse under administrator permission. Problem may be resolve.
I think you installed the SDK in "Program Files" folder . So for do something inside, must have administrator permission.
One thing that may help is to create a new test Android project.
In Eclipse, select File → New → Android Project.
Set the project name to "Test3", check Android 2.3 for the build target, type "com.example.android.apps.test3" for the package name, and type "Test3Activity" in the "Create Activity:" text box. The form should look like:
Click Finish.
Expand the entry for "Test3" in the Package Explorer. Navigate to res/values/strings.xml. Double click on the entry for strings.xml:
Set the text content of the string element having name "app_name" to "Test3":
Right click on "Test3" in the Package Explorer and select Run As → Android Application. The emulator should open and after a long while, you should see:
If these steps do not work, then you probably have an error in your installation.
Try it out and let me know.
I had the same problem earlier today. Google was largely unhelpful.
I fixed it by removing the project from eclipse, then re-importing it.
According to this bug report the problem is caused by upgrading to version 9 of the SDK.
Had the same HelloWorld problem with Ubuntu 64 Lucid / Eclipse 3.5.2 from Ubuntu repository. Restarting Eclipse did the trick, though I notice it still fusses about API level requirement when HelloWorld is run.
Running it as Administrator has solved this issue for me..
Had the same problem - occurred after I tried downloading Android platform v2.3.3 (was using 3.1 and 3.2 earlier) and it interrupted in the middle - restarted eclipse and cleaned all projects and rebuilt and the problem went away
At what point in this tutorial/guide are you running into this problem and did you make sure to include your package information in each file or ie com.something.somethingelse at the top of your class or classes?
Perhaps a registry error or maybe even a problem with activity implementation.
Please post your code if this did not start you in the right direction.
Here are a few things to check:
Make sure you have the latest version oF Eclipse (Helios)
Make sure that you have the Android SDK plug-in for Eclipse.
Now if you have done that... Make sure that any classes you add (Each screen you view on Android is a class and is called an Activity) are in your androidmanifext.xml file See http://wrenbjor.com/2011/01/12/the-androidmanifest-xml-file/ for help on understanding this process.
otherwise make sure there are no red x's in your code or it wont work.
If you still have problems post some code and we can try to help.
Had the exact same problem the other night. Upgraded to Helios (3.6) and it went away, quite possibly as a side-effect.
Under windows 7, rather than run eclipse as an admin, change the permissions on the eclipse folder so the creator/owner has full control, and do the same with the folder the android SDK is installed into.
I had installed Eclipse using the files provided by Windows' native ZIP extractor. I deleted the files and took them from 7-Zip instead. Now the error is gone. So maybe using another ZIP extraction tool will help.
Recently got this when failing upgrade using adb-manager with eclipse open (win32). As eclipse was open, upgrade failed. Then returning to my project this problem occured.
Was solved by closing eclipse, restart as administrator and cleaned project.
I had the same problem but I resolved it using following steps(using eclipse helios and windows XP ) :-
Right click on eclipse.exe.
click on Run As...
Uncheck the checkbox before "protect my computer from unauthorized activity".
And it is running for me as expected !
hope it will also run for you.