How to use releaseImplementation in a library - android-studio

I am using Android Studio 3.0 with the updated gradle plugin.
I need to use the releaseImplementation keyword in my build.gradle file as I only want the library specified (ACRA) to be built in release. The reason I only want to build ACRA in release is that I've read that Android Studio instant run does not work well with ACRA.
releaseImplementation 'ch.acra:acra:4.9.2'
The problem is, however, that it's a library so I also need to use the api key so I can transitively export in apis to the modules using the library.
api 'ch.acra:acra:4.9.2'
Is it possible to use both keywords or is there a composite keyword to use?
releaseImplementation 'ch.acra:acra:4.9.2'
api 'ch.acra:acra:4.9.2'

In Android Studio 3.0 and newer, the Android Gradle Plugin supports the new Java Library plugin configurations that allow more granular control of dependencies.
As described here, the new Gradle Dependency configurations are available for flavor- or build-type-specific dependencies.
If you wish to use the api dependency configuration for the release build Type, you would add the following:
releaseApi 'ch.acra:acra:4.9.2'
This is the "composite keyword" that you are describing. No additional dependency needs to be specified.

Related

Navigating full Android source code

How can I create and Android project that links to complete android source code, including classes in "android.annotation" ?
More precisely:
Create a new android project in Android Studio 1.5.1, Minimum SDK = API 23. Template: Add no activity.
Add this fix to resolve junit dependency: https://stackoverflow.com/a/32566057/4182868
gradle sync, make project
open class android.app.Activity
Result: a number of import statements are not resolved:
That's because those classes are actually marked as #hide, and are stripped out of the Android SDK at build time. The SDK android.jar that your project is linked with simply doesn't contain those methods and classes, which is why the IDE gets confused when it looks up the source code for the SDK classes.
(Note: We include the same annotations in the support library, but with a different package prefix: android.support.annotation.*. Those are the annotations applications should be using. But the framework itself doesn't depend on the support library, the dependency is in the other direction.)

How do I build a library into a .jar with Android Studio 1.1?

In the docs, it says:
Note: You need SDK Tools r14 or newer to use the new library module
feature that generates each library module into its own JAR file.
I have the latest SDK Tools, so I should be able to do this. But when I build my library (the compile completes without errors) I can't find any .jar file.
I set up the module in question as an "Android Library" with no Activity. It's using gradle build scripts. I'm building this to be a plugin for a Unity3d project, so it needs to be a .jar built with JDK 1.6.
The trick is that something must depend on the library for it to be built into a jar file.
So making an empty application module that depends on the library made it generate the jar. It is found in
app\build\intermediates\exploded-aar\ProjectName\LibraryName\

How do I incorporate robolectric into an existing Android Studio project?

The android ecosystem, particularly Android Studio, has been changing a lot over the last year or so. I've found many sets of instructions for incorporating robolectric into a project, written at many points during that period. And I haven't yet made one work on my project.
Which commands do I need to add to my app build.gradle?
Which commands do I need to add to my project build.gradle?
Do I need to use Junit 4 in order to use robolectric?
Are there other libraries needed? What versions?
Do my tests need to be in src/test rather than src/androidTest?
What other information do I need?
I'm using:
Android Studio 1.1.0
gradle 1.1.0
junit 4.12
hamcrest-library 1.3
mockito-core 1.10.19
dexmaker 1.0
dexmaker-mockito 1.0
I suppose that you expect to run tests from Android Studio in addition to be able run them from command line only.
I think the most up to date example of usage Robolectric with latest android gradle plugin is this.
One note: I see dependencies to dexmaker and dexmaker-mockito that gives me assumption that you use Instrumental tests instead of plain junit tests.
It is quite dumb answer with just reference but I can not be more specific until you have specific issue

Unable to use #Entity ,#Id annotations in android studio

I am a newbie in using google loud endpoints in m android app.
I followed several tutorials on developing a GAE back-end for my android app in android studio.
I made an android app and then auto-generated back-end for it.
In back-end module I created a bean and auto-generated end point class for it. But when I try to add annotations like #Entity,#Id etc then they are not recogniZed.
I have added objectify-4.0b1 jar to WEB-INF/lib in api project.
What am I missing?
Please advise.
Manish
The IDE needs to know about the objectify library. Did you use the Google Cloud Module generation built into Android Studio to create your endpoint? If so you should have your backend configured through Gradle. This would give you two options:
option 1) is add the following line to your dependencies clause in your backend build.gradle:
compile 'com.googlecode.objectify:objectify:4.0b1'
Although the latest version is 5.1.4 so if you can you should just use that.
option 2) is to go to file -> project structure, then select your backend module and add a library dependency. That will popup a search dialog where you can search for the objectify dependency and automatically add it to your module. This will update your build.gradle for you.

How to give reference to Platform SDK from Groovy IntelliJ project?

I am new to Groovy and InteliJ. I need to create a project with Groovy script. It is dependent on Axeda platform SDK from here
Using intellij, I have created a New project - Groovy Module. Used project SDK as Java JDK 1.7
I need to import some classes from Axeda SDK now. How can I give the reference to this SDK now?
You will need to add the relevant .jar files from the SDK as module dependencies.
Assuming you will need more than one .jar file and may need to reuse it for other project, you might want to create a global library for the SDK as described here. Then you can use this library for any project which needs the SDK.

Resources