Eclipse bundling provided dependencies into apk - android

I use eclipse for my android development and have a 32-bit Eclipse Juno setup where I can debug my android app via the emulator. The android app uses maven for it's build and works properly.
I recently got a new laptop and installed the 64-bit version of Eclipse so I could increase the amount of memory available to it. I have installed the same plugins (from what I can tell) and made a copy of my old workspace to make the transition easy. However, when I try debug the android project I get
trouble processing javax/xml/namespace/QName.class
Conversion to Dalvik format failed with error 1
I've tracked the root cause of this error to the fact that eclipse is including the xpp jar into the apk even though it was marked as "provided" in my pom.
When I view the pom dependency heirarchy from the 64 bit install showing it as "provided"
(don't have enough points to post a link to this)
But the libs view from the 64 bit install shows that it is getting exported anyway (bad) 1
Finally, here is the libs view from the 32 bit eclipse install showing that it does NOT get exported (good, proper behavior) 2
Been looking at this for awhile and am completley stumped as to why the 32 bit install works properly but the 64 bit one insists on exporting the provided jar. I really thought copying the working workspace would solve it, but apparently there is something else going on here.
Any help is greatly appreciated!

The solution to my particular problem was to create an empty workspace, check the project out fresh from svn, and rebuild from scratch.
Apparently me cloning the old workspace did more harm than good.

Related

Unity 2019 gradle build failed

I noticed that a lot of people have had this issue but I haven't been able to find a solution to it yet.
The main other places I found with almost exactly the same error, and recently, is here
When I simply try to install unity 2019.1 and the web GL editor component as well as the Android build component via the offline installer from the beta page, and attempt to build a basic empty scene to Android, after installing NDK and the SDK manually offline as well and pointing unity to the installations, then everything goes fine until the very end, but then it says "Gradle build failed..."
And there are about 26 errors that I can't copy now because I'm on a different device, but the main one is
"Could not resolve com.android.tools.build:gradle:3.2.0,.
And then could not get resource HTTP (...gradle-3.2.0.pom, basically)
So that link I mentioned earlier involved almost the same issue, but it's still unresolved. Basically, the unity staff guy implied that it's not possible to completely install unity offline, you would at least need to connect to the internet once to allow unity to install gradle to the home/.Gradle/cache, OR you can do it on another computer that can have unity, then copy over the cache folder.
The problems are, first of all, that even for that other guy who DID install unity and build an Android project on another computer with internet, it still didn't work for other reasons, but I'm just wondering on my case (and any similar case) where I don't have another computer that can install unity online, and the only unity capable computer is offline only, and unity is supposed to able to be installed offline via the beta components at least anyway, so how can I get the Gradle components set up?
Does anyone know where I can find a download of 3.2.0 Gradle cache?
Or is there any other solution anyone knows of at all?
I don't want to have to export the project every time then rebuild it in Android studio

Building Symbols for NDK project takes too long in Android Studio

I am working on an Android Project which makes use of the NDK and binds the rather large Boost C++ library. Upon every startup of Android Studio, the IDE takes a rather long time of about 1 hour (more or less, on an i7 quad-core machine) during the Building Symbols stage, during which it is effectively impossible to use the IDE. I guess the bottleneck is directly related to the huge number of symbols included in Boost.
Is there a known remedy to this problem? I have not seen many complaints about this problem, but this forum post seems to ask for help for the same issue: https://forum.xda-developers.com/tools/android-studio/android-studio-2-2-add-cpp-files-using-t3499634
I am facing the exact same issue - after upgrading my Android Studio installation to 2.3.3 yesterday, opening my project now faces me with at least 30 mins of "building symbols" at which point the IDE is effectively useless.
I can build the project via gradle commands in terminal, so I have no idea why this step is mandatory in AS.
I read that this may have something to do with using the NDK build (Android.mk?) vs. CMake (CMakeLists.txt), but I have not yet been able to convert over my .mk file to test this out. This is a legacy project, and the NDK portion is still somewhat of a mystery to me :(

Is it possible to debug C/C++ in Android Studio?

I'm writing an Android app that includes C/C++ code that is compiled alongside the Java code. My app is crashing during the execution of the native code.
Is there a way to step through Android C/C++ source and inspect variables as it is possible with Java source?
I am not necessarily looking for a way to step through the source from within Android Studio. That is obviously the ideal solution, however, if I need to use an external tool after starting the app from Studio, that's fine. I want to be able to step through the execution line-by-line and inspect variables.
Android Studio 1.0.2
Android NDK r10d
Edit: Stemming from the immediate response of, "Use Eclipse with ADT plugin", let me add more requirements.
This project started as an Eclipse ADT project. However, I have now migrated to Android Studio. My project is now built using Gradle, and my project directory structure reflects this. I am willing to use Eclipse; I am not willing to change my project structure in order to revert to Eclipse from Android Studio. If there is a way to open the Android Studio project in Eclipse and debug it that way, please elaborate on the process.
[UPDATE]
As of July 2015, Android Studio DOES support NDK.
You can learn more about it on this link.
[OLD]
NDK is not yet supported in Android Studio.
When we have to deal with NDK, the only solution is to use Eclipse.
EDIT
We basically keep Eclipse project with NDK feature (map in our case) and Gradle project with other (non-map) features. So everything that has to be done with NDK, we do in Eclipse and then include changes into Gradle project.
To be more precise, inside directory /src/main/ we created another directory called jniLibs and put the compiled *.so file inside architecture-specific folders (armeabi-v7a, armeabi, x86...). Then in the main class of Gradle project simply added a line
static {
System.loadLibrary("OurNDKLibName");
}
You can add this line only once per project. Maybe I am wrong but we did not have any issues for doing so.
As of version 1.3+ Preview Android Studio supports C++ debugging, quoting Android M Developer Preview & Tools:
Most notable is a much requested feature from our Android NDK & game developers: code editing and debugging for C/C++ code. Based on JetBrains Clion platform, the Android Studio NDK plugin provides features such as refactoring and code completion for C/C++ code alongside your Java code. Java and C/C++ code support is integrated into one development experience free of charge for Android app developers.
It isn't wasn't isn't working very well.
hello-jni fails failed with:
Starting LLDB server: run-as com.example.sample
/data/data/com.example.sample/lldb/bin/start_lldb_server.sh
/data/data/com.example.sample/lldb
/data/data/com.example.sample/lldb/tmp/platform.port1442695333842 "lldb
process:gdb-remote packets"
Error while launching debug server on device:
com.android.tools.ndk.run.DebuggerContext$StartServerException:
java.lang.IllegalStateException: Failed to read platform port
/data/data/com.example.sample/lldb/tmp/platform.port1442695333842
I'm using 1.4RC1
compileSdkVersion 23
buildToolsVersion "23.0.1"
And the "app-native" run configuration #Gerry mentioned. It's nearly there, but I can find no trace of an lldb directory in my app's private data folder. I do find a 400kb gdbserver in the lib directory linked from there, with my own *.so right besides. Unfortunately the option for debugging with gdb instead of lldb has gone with the upgrade from 1.3 to 1.4. NDK 10e ships a 400kb gdbserver binary in ndk\prebuilt\android-arm\gdbserver which it is (I guess). On September 15th the gdb debug howto https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB was updated. This is harder than logcat debugging IMO, but a current topic, sorry to be so negative but I don't believe lldb actually works yet.
I have run hello-jni and reached the same conclusion.
So in answer to your question, it is not yet possible to debug C/C++ in Android Studio. Sorry this wasn't the answer you hoped for and I hope to be proved wrong with conclusive evidence to the contrary, but right here, right now, no chance!
UPDATE I raised an issue where I was given a fix for one phone.
UPDATE2 Too early to tell, it is experimental after all, but I am occasionally failing to connect, often if not always getting out of order stepping and breakpoints with nonsense parameter values. I just set a conditional breakpoint that didn't fire but the logcat shows it should. Initially I assumed it was my logical error, but it goes deeper.
Simply hitting breakpoints at all is very helpful but it is still a million miles short of Java debugging, or Vis Studio C++ debugging.
UPDATE3 Gone back to stable 1.3.1 as the canaray channel version was pausing for a toilet break every keystroke. While native debug build at least launches with my "fixed" phone, no breakpoints are hit even in hellojni, or a slightly extended version to give more opportunity. I'm used to logcat now but have had better degbugging experiences with Android, NDK and Eclipse. A more elaborate solution is also easier to break, but at least it works.
Yes, Android Studio does support C++ debugging at least with Android studio 1.5.1 and android-ndk-r10e.
In the old days, you will have to write make files Android.mk and Application.mk in order to build the C++ code in Android Studio. You don't need them any more. As long as you put them under the jni folder, gradle will be able to pick it up and compile it. You should see something like the following:
And also allow you to set break point and debug it.
You should follow this step-by-step tutorial and learn more about it. And read more about the documentation here. I've uploaded a complete working example so that you can download and try it out on GitHub.
With Android Studio 1.4 from tools.android.com, debugging is possible. When you open/create a project with C++[jni] code in it, Android studio would create a new configuration, something like $(module_name)-native
I would select this configuration, sync gradle, build, set breakpoint etc and run it with Android Studio. After a long wait, my debugger is connected, app is broken in[I think you could also set breakpoint at this time]; this break is not at my set break points, I let it go in android studio and my breakpoint is hit. Hope this helps
Some samples are supposed to work with android debugger
yes! it is possible to debug native code in android studio. As from the updates Android Studio 2.2+ support in built tools for debugging native code.

Android Library project organization

I have an Android Apps (A) project that depends on a Library project (B). The library project contains code as well as third-party jar files and some other jars that were exported from projects C and D. In Eclipse, I have project B specified as a library project.
However, when I connect my device and run project A (Run As -> Android Application), it crashes on the device and when I examine the LogCat output, there is a NoClassDefFoundError exception for one of the classes that exists in the jar files of project C.
When I unpack the B.jar file in Project B's bin folder, it does not contain anything else besides the META-INF/ folder with an empty MANIFEST.MF file. So this indicates that something seems to be going wrong someplace, but I'm unable to figure it out.
Could anybody help me with this issue?
Are you working with the latest ADT plugin and SDK revision? That is rev 22.x. If so there has been an important change to the dependency management.
Possible solution
For some reason the contents of the Order and Export tab has completely changed and you now have to export the Android Private Libraries from your library projects. See screenshot below:
More details
The tricky part of this change is that your project still compiles properly in Eclipse so you're not aware of any issues. Until you deploy the app on an emulator or device and you get the ClassDefNotFoundException on any call of a library project.
Not confirmed but I believe this is related to recent changes for maven support, also related to android studio preview
Similar change in the past
This reminds me of a similar change in the update to rev 17 where the lib folder suddenly changed to libs and all content from the original lib folder wasn't packaged so you wouldn't see any issues in eclipse. Only once installed on a device.
More information that 'issue' is available on this link. If you search on stackoverflow for "sdk 17" and "classdefnotfound' you'll also get enoug questions about that change.

IntelliJ IDEA is not correctly forming Android project hierarchy?

I posted this question on the IntelliJ community forums but it seems as if they aren't very active so I'll just post it right here on S/O. I'm new to IntelliJ and I'm switching to use it from Eclipse which was really buggy and not useful to my needs. However, I'm attempting to build an Android project in IntelliJ Idea and it is only creating a .idea folder and the src directory without any inner files in them like it should. I've got the Android-SDK properly installed and I'm using JDK 1.7 and I'm even following the directions to properly start an Android project from the IntelliJ Wiki (found here) but it still leads me to no success. It seems as if I've got the Android Support plugin already installed with my program but then again I'm not really sure. Can I get some help please so I don't have to revert back to Eclipse again? Thanks.
Try to delete Android SDK and install it again, then download at least one Platform. IDEA runs SDK tools to create Android project template, for some reason it's failing on your system.
Check if it works better with JDK 1.6.
See the screencast that I've just recorded.

Categories

Resources