Get Android NDK crash reports with Unity 2019.3+ - android

Since Unity 2019.3 the Android build process has changed and now the gradle project contains two modules - a unityLibrary module and launcher module.
I am having trouble uploading native symbols as I cannot apply the plugin to the unityLibrary module, and only works in the launcher. Is there a certain way I can achieve this?
When I run uploadCrashlyticsSymbolFileRelease task that is only present on the launcher module, I receive this error:
Could not find the file generated by Google Services. Please check your Firebase project configuration
The configuration file is in the unityLibrary module.
Is there any way to move the task to the unityLibrary module? If I move the crashlytics plugin to the unityLibray module the error changes into:
Crashlytics was applied to a project without an Android plugin. Please make sure the Crashlytics plugin is applied after the appropriate Android plugin for your project.

The tricky bit is that Firebase is still compatible with versions of Unity that do not support gradle integration. Because of this, the build pipeline in Unity re-implements the functionality of the google services plugin (namely generating the values.xml file).
I've personally put some effort into massaging the mainTemplate.gradle file to work with gradle plugin, but haven't gotten the NDK upload to work yet. Some notes that may help:
The External Dependency Manager for Unity (EDM4U) will both update the mainTemplate.gradle file if available but will also process google-services.json and drop the output into Assets/Plugins/Android. You'll likely want to run it once to generate the dependencies, delete the values.xml, and then disable EDM4U to prevent it from regenerating that file.
The Unity SDK is based on C++, and the aar archives that bind C#, C++, and Java are packaged into local maven repository in your Assets directory. This will make it hard to relocate your project after generating it (ie: try to do all your work Unity side if possible).
Because you'd be short-circuiting Firebase's processing of values.xml to use the plugin, you'll need to make sure google-services.json actually makes it into your Android sourcetree. Assets/StreamingAssets might do this automatically but you may have to write a build script to copy it over.
Finally, the team is aware of the desire to debug NDK code in the Unity Crashlytics plugin. There aren't any public timelines available, but in lieu of a good answer opening an issue on the quickstart or posting to the mailing list might could be a good way to try to work through the process.

Related

"Uses reserved file or directory name 'lib'" error when trying to build android app bundle

I'm trying to build an app bundle but I'm getting the following error:
File 'root/lib/x86_64-MacOSX-gpp/jni/libjunixsocket-native-2.0.4.jnilib' uses reserved file or directory name 'lib'.
For what I've seen from similar questions, this issue is normally solved juggling dependencies or files in the project structure, but in this case it seems to point to a native library involved in app architecture if i'm not mistaken. Any ideas how to solve this?
It looks like you are adding a dependency as a jar instead of an aar.
The aar contains the information of what files should be considered as Android resources, native libraries, etc. in the app. A jar is just a plain list of files without Android concept. Because the jar you're depending on contains a directory lib, the files would normally end up being considered as native libraries, but because the files come from a jar instead of an aar, the build system warns that it's unlikely to be a native library and may have unintended consequences at runtime.
Try to package that library as an .aar instead of a .jar. See this documentation: https://developer.android.com/studio/projects/android-library
Edit:
Note that this file could not be loaded by the Android platform if it was included as is in the APK, so even though the previous build systems would allow you to put anything in an APK, the Android App Bundle is more restrictive to ensure that you don't accidentally put unnecessary files which would increase unnecessarily the size of your app.
Ok it is working now! Steps I used to found the problem (thanks for pointing me in the right direction #Pierre)
Run a gradle build --scan from your terminal or go to the Gradle tab in Android Studio, select :app, help , androidDependencies to see your dependency graph.
Search the dependency graph for the library name related to the problem ( in my case I searched for socket, there was no match for libjunixsocket for example).
Going upwards on the dependency tree I realized it was caused by the 'io.voucherify.android.client:voucherify-android-sdk:2.1.0' dependency.
I just added #aar at the end of the dependency implementation, and I managed to build the app bundle.
implementation 'io.voucherify.android.client:voucherify-android-sdk:2.1.0#aar'

Developing Android 9.0 eSIM LPA (system app)

Trying to develop android LPA system app for eSIM with the new Pie API.
The doc says to extend the abstract EuiccService class. But this class is not in the official SDK, and the link in the docs just leads to corresponding file in the android source repo.
I tried using this file/class as a dependency, but it references other internal android classes/annotations and causes build/IDE errors.
Does anyone have an idea how to use this?
Do I really have to pull android src code and somehow reference required class from it?
EDIT: I think I've solved it, found couple of potential solutions, but they were a bit cumbersome. Used the android.jar from here: https://github.com/anggrayudi/android-hidden-api (contains modified android.jar with hidden APIs and internal resources). It didn't work when i replaced the whole file and resulted strange build errors, but i manually transferred the android\service\euicc\ folder to original android.jar of android-28 sdk and it works perfectly (class is available and apk builds without issues). And no need to waste time pulling and building AOSP.
EDIT #2: apparently not fully fixable atm. There's issue with android gradle plugins (at least 3.2.x-3.3.x) where during full sync some build task generates mock classes from android.jar and process fails if it's modified (discussion is here: https://github.com/anggrayudi/android-hidden-api/issues/46). Error looks like this:
Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform
There's a workaround for that, though inconvenient:
when you need a full sync for the project, replace the android.jar with original, run sync, restore modified android.jar, the IDE now will run indexing and classes will be available again with build working until next full sync.
Will update this post if/when it's fixed or new solution is found.
EDIT#3: here's probably a final solution for EuiccService case (turned out pretty obvious):
Instead of adding 'android/service/euicc' folder to android.jar, just put it in a separate library and add it as a compileOnly dependency. Since the classes were not in the SDK, the lib should not cause conflict (would be the case if you need to use modified framework or access hidden APIs in already existing classes).
If you are going to create a System APP, you will do it in several ways:
You could call a part of the SystemAPI (a method for example) by reference.
You could make the aplication as a part of the AOSP Project (Downloading the AOSP code, and introducing your app as part of packages/apps/)
You will be able to access system APIs on a rooted device or if you have system permissions (this happens when you flash your app into the device as part of the system image).
However, if you want to be able to call the EuiccService class from Android Studio (for coding purposes), you'll need to add the Android framework jar to your project.
The steps are provided below:
First, you will have to download and build AOSP and generate a framework jar for your target Android version. Check the documentation here to get an idea of how to download and build AOSP.
After a successful build all framework classes are compiled into a jar called classes.jar which can be found at the location out/target/common/obj/JAVA_LIBRARIES/framework_intermediates.
Get this classes.jar and add it to your Android project as a jar file.
Gradle sync the project and start coding.
Please beware that you WILL NOT BE ABLE TO run this app on an Adnroid device where you do not have system permission for this app.

Composite Builds in Android Studio

I am looking to use Gradle's new composite build feature in an Android Studio project called MyProject that includes both an Android Archive library (.aar) called DroidLib and a Java library (.jar) called JavaLib. These libraries are currently checked into version control due to my inability to get Gradle to pull dependencies from our internal Artifactory. That is, the DroidLib project has the JavaLib.jar checked into git under the libs folder and the MyProject project has the DroidLib.aar checked into git under its libs folder. I would like to make changes in both DroidLib & JavaLib while debugging and consuming the changes in MyProject w/o manually rebuilding from the dependency projects.
The new Composite build feature in Gradle offers just the thing I need however it looks to be something triggered from the command-line via a flag such like this:
--include-build ../DroidLib
In the Gradle docs it looks like this flag allows Gradle to override a dependency declared in the local project with a similarly the project declared in the included build. This would make sense since they both would use the same group/name/version scheme. I'm having trouble trying to understand how I would use this from Android Studio where my DroidLib dependency is declared as a local filesystem based dependency:
compile(name:'DroidLib-1.19', ext:'aar')
How would the command line flag tell Gradle which dependency is overridden since there is no apparent group/name/version declared on DroidLib? Also how could I make use of this in my app launch run config which uses the Gradle-aware make feature? Is there a way to pass add'l options to the Gradle-aware make or am I over-thinking what has to happen here?
Short answer
It is not available yet (it is in IntelliJ 2016.3).
More details
According to this blog post, the feature is in IntelliJ 2016.3:
With composite builds, everything is much, much simpler. All you have to is to attach the Gradle projects of these libraries via the Add button in the Gradle tool window (my-utils in our case), and then select Compose Build Configuration from the context menu for the original project.
Unfortunately, according to this release note, Android-Studio 2.3 is based on IntelliJ 2016.2. So we'll have to wait for IntelliJ 2016.3 to be merged into Android Studio =/.

Difference between module, libraries, jar, library projects, gradle projects, aar and jar

I work for a company which has a android mobile application developed by an offshore team. I have access to GitHub repositories.
I am piecing together the android app block by block and it is giving me hell.
How do I distinguish between module, libraries, jar, library projects, gradle projects, aar and jar. Can someone please give me a practical definition. NOT out of a freaking google search. I have Google too.
PS yes I am a noob and not proud of it.
I'm just giving a brief description about each of these. I hope I'm clear.
Module : A Module is an component of your application that can build / test independently and re use it in another application if required.
Libraries : AAR files, JAR files etc.
JAR : Java library
AAR : Just like JAR, only difference is that it also contains android specific files like resources etc.
Gradle Project : Gradle is just a build system which is used by Android Studio to build the android project. Its very much powerful as compared to the build system which was used in Eclipse earlier.
Library Project : An Android library project is similar to an Android app project in that it also includes a project manifest file in the project’s root directory. Also, this directory contains src, res, and other directories that you also find when building an app project.
However, there is a significant difference. You cannot compile a library project into an APK file because a library project doesn’t describe an app. Instead, it provides reusable code and resources that contribute to an app when the app’s project and source code refer to the library project. At build time, this code and these resources are merged into the app’s APK file.
To explain more on this, let me give you an example :
Say you want to use a networking library volley for making API calls, now since this is an open source library from Google you can clone it making customisations as per your requirement.
You can make volley library as your Library Project, build it independently, unit test, etc.
Now say you started building an application where you need to make HTTP calls so you need to add volley library to your project. You have two choices for that :
Compile your library project volley, generate the aar file and add it your app Project.
Add Volley as module in your project. (If you choose this option you can make changes to volley library in same studio project since it will act as a component in your project)
Please let me know if something is not clear.
1.) Module
A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules and one module may use another module as a dependency. Each module can be independently built, tested, and debugged.
There are 4 type of module in Android Studio.
Phone & Table Module
Android Wear Module
Android TV Module
Glass Module
2.) Support Library
The Android Support Library offers a number of features that are not built into the framework. These libraries offer backward-compatible versions of new features, provide useful UI elements that are not included in the framework, and provide a range of utilities that apps can draw on.
Support libraries provide a range of different features:
Backward-compatible versions of framework components.
UI elements to implement the recommended Android layout patterns.
Support for different form factors.
Miscellaneous utility functions.
3.) Jar file
JarFile is used to read jar entries and their associated data from jar files.
for more detail visit this : https://developer.android.com/reference/java/util/jar/JarFile.html
4.) Android Library Project
The Android team introduced a new binary distribution format called Android ARchive(AAR). The .aar bundle is the binary distribution of an Android Library Project.
An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. This allows that an AAR file is included in the build process of an Android application similar to a JAR file
5.) Gradle and Gradle Project
Gradle is an automated build toolkit that allows the way in which projects are built to be configured and managed through a set of build configuration files. This includes defining how a project is to be built, what dependencies need to be fulfilled for the project to build successfully and what the end result (or results) of the build process should be. The strength of Gradle lies in the flexibility that it provides to the developer. The Gradle system is a self-contained, command-line based environment that can be integrated into other environments through the use of plug-ins. In the case of Android Studio, Gradle integration is provided through the appropriately named Android Studio Plug-in.
for more detail visit this : http://www.techotopia.com/index.php/An_Overview_of_Gradle_in_Android_Studio

Duplicate file when deploying apk

This problem seems to come up for a few people, but I haven't been able to apply the solution suggested in other threads for one reason or another so...
I am trying to build a simple android app with an embedded webserver. The server of choice if jetty. I am using maven to manage dependencies with the maven-android-plugin. I have added jetty-server v8.x as a dependency with the default scope. When I try and deploy my apk to the sandbox I get an error
Found duplicate file for APK: about.html
So the file in question is from the jetty package, or rather it is found in two jetty packages, one being a dependency of jetty-server. Other threads out there seem to be suggest I delete the file from one jar or the other but this is not really a scalable solution as I am not the owner of the jars.
Is there a more general solution to this problem? Something that manages the conflict and build or deploy time?
I should note, I am a bit of a Java noob, and have gone the NetBeans and maven route because this is the toolkit I'm familiar with.
OK, found it. The solution is to build using the following command
mvn android:deploy -Dandroid.extractDuplicates=true
There are a couple of issues:
First, to integrate Jetty, your project is going to need a pom.xml file. The Android APK (as-is) does not know how to resolve a pom with Maven dependencies without some sort of bridge. So, you'll need to install a few plugins for Pom management onto Eclipse. Follow the instructions here: http://rgladwell.github.com/m2e-android/
(I found it easier to create a new project using the method described here rather than converting my existing Android app to a Maven project, but I'm sure it'll work either way.)
Second, once you've installed this, you're going to have to make sure your pom.xml contains the necessary dependencies, build goals, and variables. So, open up your pom.xml, and make sure you have the following:
In the "build" node:
sourceDirectory -> src
defaultGoal -> install (I suppose...)
In the "dependencies" node:
... all the jetty/cometd dependencies (org.cometd.java, org.eclipse.jetty, etc.)
Third, you should know that you can't just click the green run button and launch the app via ADB. You have to install it the maven way (Run As -> Maven build/install/test/whatever)
You should open up your war file and check if you actually have two about.html files in there. Some time ago I had two web.xmls in my war files. If you actually have duplicates then you should try to exclude those files.
Maybe you have one file in your project and the duplicate is generated by the maven plugin.
I also just realized that you're probably already properly using the android-maven plugin. One other important tip: change the scope to runtime on the jetty dependencies. This builds successfully for me, whereas using the default scope (compile) always threw the duplicate file in APK error.

Categories

Resources