How to use Android NDK and Fabric at the same time? - android

I have a Crashlytics-enabled app (which is now part of Twitter's Fabric) and I need to add some JNI functionality using the Android NDK.
I've switched to experimental gradle as Android Studio prompted me that way:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental
When I've applied the necessary changes and tried to sync, I've got the error:
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.
I've googled the error and found out that it's a problem between Fabric and experimental gradle, and Fabric team doesn't really seem to care about fixing it any time soon: https://twittercommunity.com/t/gradle-experiental-support/53441.
I've stumbled upon Issue with experimental gradle: The android plugin must be applied to the project but I have no idea what to do there, and I'm not sure if it's the right way to go?
How can I use Android NDK and Fabric in my project?

So gradle-experimental and Fabric don't mix.
Solution:
1) update to latest Android Studio 2.3.1
2) follow this tutorial to drop gradle experimental: https://developer.android.com/studio/projects/add-native-code.html
What I did was create a new temporary project with C++ support enabled and added a blank activity.
Then I opened my current project and the temporary project and copied the necessary changes into my own project.
After I was done (about 1 hour of work) I was able to build my C code into a library, load the library into my project, and make the JNI calls.

Related

React Native: what's the difference between Android Gradle Plugin in build.gradle file and Android Studio?

In my React Native project I'm using react-native#0.63.4, and following the migration guide from a previous version, I have the following line in my android/build.gradle file:
classpath('com.android.tools.build:gradle:4.1.3')
When I recently opened the project in Android Studio it recommended I upgrade my Android Gradle Plugin from 4.1.2 to 4.1.3.
What I Want To Know: What's the difference between the Android Gradle Plugin version referenced in my build.gradle file and the one in Android Studio? What effect does each have on the other, and how is each used in my app itself?
First of all, let's start with what build.gradle does:
Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software.
The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps.
Gradle build scripts are written using a Groovy or Kotlin DSL.
There are several differences on versions like:
Incremental Builds
Build Caching
Incremental Subtasks
Incremental Annotation Processing etc.
When you update Android Studio, you may receive a prompt which is telling you upgrade your project gradle. This is because you upgrade your Android Studio plugin, not the project. With this upgrade you can have some developed functionalities in gradle like above.

Gradle new version and Build version

I have updated SDK and I am using Android studio 2.0(preview). So I think all things are enough updated. For me and for my newly created projects all things work fine. But When Ever I download the code from github I always gets error of gradle versions.
So It is kind of annoying. Well I admire a lot of things are already fixed by gradle while importing that github project . But once the gradle version error occur its some times gets hard to know the exact reason. And honestly I know things about gradle quite enough , but I always get it solved by hit and trial method. So I have many confusions which I am posting below as a questions
How to know what is new gradle version is going on.
How to know which things are now forbidden in the new version of gradle
How to know which support dependencies will work with new gradle version
How to know which version of build tools will perfectly match to gradle.
I think there are many stupid things in these question and I google these questions, but end up with deciding to ask you guys as you guys can clear me formally and casually.
please answer my question if you know this thing deeply.
Android Gradle Build systems are software tools designed to automate
the process of program compilation .
How to know what is new gradle version is going on.
The Android build system uses the Android Plugin for Gradle to support
building Android applications with the Gradle build toolkit. The
plugin runs independent of Android Studio so the plugin and the Gradle
build system can be updated independently of Android Studio.
You can Mouse Hover On classpath for checking latest Version .
How to know which things are now forbidden in the new version of gradle
You should check Android Plugin for Gradle Release Notes
For classpath 'com.android.tools.build:gradle:1.3.1'
Fixed the ZipAlign task to properly consume the output of the
previous task when using a customized filename.
Fixed Renderscript packaging with the NDK.
Maintained support for the createDebugCoverageReport build task.
Fixed support for customized use of the archiveBaseName property in
the build.gradle build> file.
Fixed the Invalid ResourceType lint warning caused by parameter
method annotation lookup when running lint outside of Android
Studio.
Now For your 3rd and 4th questions you should check manual testing .

Eclipse and gradle android-library projects

I have a main Android project which references 4 other Android-Library projects in gradle. It compiles just fine and i can deploy it via gradle commandline, however I would like to debug my code using eclipse.
Whenever I load up the projects in Eclipse using the gradle integration plugin for Eclipse, eclipse won't even recognize them as library projects and instead treats them like normal android applications. Is this behavior normal or is something wrong with my gradle build script or does eclipse simply not support such a setup yet? Running/debugging the main application in eclipse just installs the individual libraries as regular applications which results in my main application not being able to find the specified classes.
My gradle build script is basically a c&p from Mike Gouline's sample project https://github.com/mgouline/android-samples with "apply: android" replaced with "apply: android-library" for my library projects.
Eclipse doesn't properly support Android Gradle projects. The Android plugin has a lot of specialized support for android-library modules that Eclipse's Gradle integration doesn't know about. For the time being, if you want full IDE support for Android/Gradle, Android Studio or IntelliJ with the Android plugin are your only choices.
We know the situation for people who are using the Gradle build system and want to use Eclipse isn't great; it's something we're thinking about, but we don't have anything definite on the roadmap yet.

Pre-alpha Mapbox integration into Eclipse Android Project

I have an existing Eclipse android project that I would like to use the pre-alpha MapboxSDK with. I have tried using gradle to try to build the library into my project, but have been unsuccessful. Is there someone out there that would be able to detail a step by step procedure for importing and integrating the SDK into an existing project?
Best place to ask would be on the issue tracker for the project, and to share the specific error that you happen upon in trying to set the project up.

Migration from Eclipse to Android Studio

So,
as it seems that more and more people are using Android Studio i got curious and wanted to take a peek at it.
I have used Eclipse up until now and wanted to migrate a project to Android Studio. So i exported a gradle buildfile from within Eclipse, as android.developer.com suggested.
That worked fine, now i wanted to import that into Android Studio 0.3.2
When trying to import i got that Unable to import Eclipse project to Android Studio error. Now it is building.
But it got a new suprise, now before it is finished building, its asking specifically for an older Version of Gradle(1.6)... Ok, i can do that. Which leads me right back to the first error. So i tried this - Gradle version 1.6 is required. Current version is 1.8-20130730220035+0000
I can however create a New Project with Android Studio.
I've tried this for about an hour now and im getting sort of pissed, because it doesnt seem to know what it wants. Is it some sort of Bug or did i make some sort of mistake.
You're using a very old version of Android Studio. I'd recommend upgrading to 0.4.3. Versions later than 0.4.0 allow direct import of Eclipse projects instead of requiring you to do the cumbersome (and as you've seen problematic) export of projects from Eclipse; it's smarter about setting up the right plugin and Gradle versions. 0.4.3 has some important bugfixes over 0.4.0-0.4.2.
I've just migrated my projects. Here is two suggestions from my side.
Take the latest Android Studio.
Do not export / import projects from Eclipse. Most likely you are going to have errors in the project after this step. Starting from a clean project, which builds, will safe you a lot of time and avoid unnecessary frustration.
Create an empty Android Project in Android Studio. It must build without errors (⌘ F9). The start to enhance it using official Gradle Plugin user guide.
Create libraries folder and add all libraries in there one by one. Update build.gradle dependencies as mentioned in user guide. Make sure everything builds successfully.
After all libraries build you can copy-paste sources, resources and assets from Eclipse project to corresponding folders of Android Studio project. Make sure everything build as expected.
Now you can start with more advanced configuration like ProGuard configuration, release certificates etc.
I've done it in a couple of hours. Hope this helps you too.

Categories

Resources