I have recently begun maintaining an Android app that is not compliant with Google's requirement for 64-bit native libraries. The app itself does not directly depend on native code but in the generated apk a native library named libcproxy gets included. I can only assume that this is needed by one of the apps dependencies but so far I have not had any luck in finding the artefact in question. The shared library also seems a bit elusive as I have not been able to find many references to it online.
Is there perchance a gradle command or similar that can shed some light on which artefact includes the library?
I have tried excluding the shared library in the hope, that I might get an unsatisfied link error but so far I have not been able to make the app crash due to missing the library.
You can display a dependency tree with :
gradlew app:dependencies
Related
I'm currently trying to build a Unity project for Android, which utilizes Mapbox, Firebase, Unity's in-built AR Foundation, and a bunch of smaller packages from the Asset Store, which cannot be the source of the problem.
I built the project before adding Firebase successfully, but now I get the following error:
D8: Program type already present: com.google.gson.FieldNamingPolicy$5
(full version posted here pastebin because it's a lengthy one)
Version Numbers:
Unity 2019.3.0f6
Firebase Unity SDK 6.14.0
Mapbox Unity SDK 2.1.1
As far as I can tell, the problem is based on Mapbox and Firebase having dependency issues with each other. However, I have no clue how to fix them.
I tried every plausible solution I could find, including custom-grade templates, Gradle settings, trying internal builds on an older version of Unity (2018.3.14f1), exporting the project to Android Studio, then building from there and more.
None of this worked for me, sadly.
Are there any other methods I could try to fix this?
Thank you in advance!
P.S.: If I try to disable R8 as proposed in the error message, I get a java.io.IOException about a read error related to the "Duplicate jar entry [com/google/d/d$5.class]", but in general, no matter what fix I try, I usually end up with a different error message than with the other approaches.
I have an idea about what may be happening, but don't have an immediate way to test this solution.
It looks like there are two copies of the Google gson library included in your build. Inspecting mapbox-unity-sdk_v2.1.1, I see that there is a file gson-2.8.5.jar included in the unity package. Since the build is apparently including gson as a side effect, you may be good just deleting this file. But I suspect that the support libraries that are also included may cause an issue.
Given this, I would suggest three avenues of remediation:
1) you may want to use the External Dependency Manager for Unity to resolve these files for you. This is included in the Firebase SDK (and is a completely open source project so you may want to request that MapBox use it in the future).
I would recommend reading this article to fully understand what's happening, but what you want to do is create a MapboxDependencies.xml file in an Editor folder (ex: Assets/Mapbox/Editor/MapboxDependencies.xml) and include all the dependencies under Mapbox/Core/Plugins/Android:
<dependencies>
<androidPackages>
<androidPackage spec="com.google.code.gson:gson:2.8.6"/>
</androidPackages>
</dependencies>
And delete the related jar/aar files when you're done.
Note that you will have to track down maven repositories for these, otherwise I would include a complete xml file for you.
Now libraries that may cause you issues are all the support libraries. It looks like Mapbox may still be using the old support libraries prior to Android Jetpack. There are mappings here, so I'll take a first stab at their Dependencies.xml entries for you:
<dependencies>
<androidPackages>
<androidPackage spec="com.google.code.gson:gson:2.8.6"/>
<androidPackage spec="androidx.appcompat:appcompat:1.1.0"/>
<androidPackage spec="androidx.legacy:legacy-support-core-ui:1.1.0"/>
<androidPackage spec="androidx.legacy:legacy-support-core-utils:1.1.0"/>
<androidPackage spec="androidx.media:media:1.1.0"/>
<androidPackage spec="androidx.legacy:legacy-support-v4:1.1.0"/>
<androidPackage spec="androidx.vectordrawable:vectordrawable:1.1.0"/>
</androidPackages>
</dependencies>
The other problem you would typically run into is that under normal circumstances, you'd have to recompile all the libraries that relied on the old support libraries to reference the new androidx ones. Jetpack did come with a tool called Jetifier that should do this automatically if you enable it in the External Dependency Manager:
Although you may run into this issue on some configurations of Unity 2019.3 and later (workaround in the issue thread).
2) Alternatively you can add a mainTemplate.gradle to achieve the same goals. I would recommend using the ExternalDependencyManager, but by deleting the aar/jar libraries and adding them as dependencies in mainTemplate you'll effectively achieve the same outcome.
3) If you resolve your dependencies without mainTemplate.gradle - all of Firebase's aar/jar files will get added to Assets/Plugins/Android/Firebase. If you deleted all of the conflicts with Mapbox libraries, you may get to the same point. This feels a bit more dangerous to me and the support libraries may be harder to work with (you'd have to track down the androidx libraries on your own for instance) - but might remove some of the moving pieces if the dependency managers are new to you.
I hope that all helps!
--Patrick
I've been working on an Android app project. I'm using quite a few libraries (because why redo work that someone else has done to make other people's life easier?).
My question is: what are the costs of importing libraries in a project? (I'm talking about the implementation XXX.YYY:v2.0.0 type of line added in the build.gradle dependencies list.)
Just as an example (though please provide a more encompassing answer): when compiling and publishing my application, does it take all of the libraries' classes and methods and put them in my application, thus making it much heavier than it would need to be?
Each library dependency requires an additional download while you compile your app. So these will increase the amount of time required to compile.
The code for each library is included in your final APK so they will increase the size.
For Every Library a download is necessary In order to built your app.
e.g If you want Libraries regarding to Firebase then You download the Library by adding the Firebase Project to your App. In build.gradle File you see the dependencies after you add them to Your Project App.
I am a student and currently working on a project where I am trying to connect my game that which I have created with Android Studio. A neural network has also been made with Tensorflow which is going to be used for the android game.
The problem is that Android Studio uses a build tool which is called Gradle and Tensorflow uses Bazel. To solve this problem I have been trying to build my android game with Bazel but I am stuck at the part where I have to add the used external dependencies. For the game I use the following dependencies:
Appcompat
Support
Percent
Which supposedly should come with the android support repository.
I have looked at http://www.bazel.io/docs/external.html and several other sources but I still do not understand how I can add the dependensies. Could someone provide me with an example how to do it with for example appcompat and what I have to do to make it work? Or is there another way which would be easier?
EDIT: I have have been succesful in building the android example of Tensorflow but this: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android
But it doesn't include dependensies which I am using.
You may want to look at the Makefile support we just added for Android:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile
It's still very experimental (and fiddly), but should let you build a static library that you can more easily use in your gradle project.
Nevermind I resolved my issues, after removing the depensies I checked the WORKSPACE file. It seems I didn't set the package correctly, my bad.
We are building an app that imports, via Artifactory, a collection of libraries that are then referenced from the main app.
We are in the process of localizing our app. We can localize our libraries and verify it works by directly using the libraries in a test app. When the libraries are pushed to our artifactory, we can then import, via gradle, the libraries for use in our app.
We can verify that making code changes or even changes to English strings in the libraries all work, and when pulled into the main app, any such changes are reflected correctly. However, while we have localized our libraries (into Spanish), when pulling the localized libraries into the main, the Spanish strings are not used. Instead, it uses the default (English) strings. We have looked at the libraries on our artifactory, downloaded the AARs and verified that the snapshots do in fact contain the localized strings but for reasons we can't figure out when imported into the main app, it does not use them.
We're confused why this is the case - wether we are doing something wrong or if there is a bug in gradle or Android.
Does anyone have any insight? I apologise for the vagueness but the issue is rather esoteric so I'm not sure what code if any might be relevant to solving the issue. Feel free to ask for further clarification.
UPDATE:
We decided to import the .AAR directly, by placing it in a libs/ directory and referencing it in our Gradle build. It now works fine, the library in question is correctly localized.
So it would seem the issue comes from when the snapshot is downloaded from the repository.
The app is looking at the wrong version of the library: the previously released version rather than the latest SNAPSHOT.
Full disclosure: James and I work together.
As you can see from my passed 3 questions I am having major problems with my project setup. I am getting lots of very specific errors that seems like nobody can answer them. I am getting hugely frustrated. So I am going to try a fresh approach. I will describe how I would like my project set up and if somebody could give me some brief steps to follow I would be very grateful. After messing around with this for around a week I believe I have some knowledge but maven seems to be incredibly difficult to understand.
I am writing a library which will be used in 2 projects. The major libraries I would like to use are roboguice, robolectric and jackson(json library). I would like to have a way to test the library but I am unsure if this should be in a different module or not. Robolectric seems to suggest it should be in the same module. I am unsure how I should use this library in the other 2 projects. I have been looking at this http://code.google.com/p/maven-android-plugin/wiki/ApkLib but unfortunately the website tells me next to nothing about how I should create the apklib.
If it is possible I would also like the other 2 projects to have a dependency on that library and build it automatically.
I have been using this site to create the maven project http://stand.spree.de/wiki_details_maven_archetypes
But I have been running into issue after issue. If anybody can point me in the right direction I will be very appreicative
Even if maven is (almost) a foreign country to me, I had some moderate success setting up a maven project and interacting with it using intellij. I wanted to use it because it looked the easiest way to have robolectric working with intellij.
I wrote a blogpost you can find here
What you need is:
Maven android sdk deployer https://github.com/mosabua/maven-android-sdk-deployer
Maven android plugin http://code.google.com/p/maven-android-plugin/wiki/GettingStarted (using android archetypes is just fine)
If you want to build an apk lib instead of an apk, just specify apklib in the packaging tag
PS: I also saw this a while ago, but never gave it a try.