Navigating full Android source code - android-studio

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.)

Related

Importing LIBGDX library gdx-backend-android.jar into Android Studio Project

After a hiatus of a couple of years I'm picking up Android development again.
I installed the newest Android Studio(4.1.1) with the latest Android SDK version (Android 11, API 30). After that I created a new project with gdx-setup.
If I add the old java source to my newly generated project I get this error:
error: package com.badlogic.gdx.backends.android does not exist
I'm not sure how to add this jar into the new project. In the Gradle configuration I see mentions of the backend, but it's not available.
I also downloaded the 'gdx-backend-android.jar' from the nightly build and put the jar in the Android library folder, all to no avail.
Does anyone actually know how to correctly add this dependency into my project?
I added the jar but still have an error, don't mind the other errors, I first need to fix the GDX import.
The project dependencies are managed by Gradle, so there is no need for you to directly touch any .jar files at all.
The most likely issue you're facing is that you are trying to use Android-specific classes from the core module, which is platform agnostic.
In a typical libGDX project, you do almost all your game code in the core module so it can easily be compiled for any platform. The code you showed above would be in the android module, but your LiveWallpaperStarter class would be part of core.
Some might say there's no reason to use core at all if you're making a Live Wallpaper, since it can't run on any other platforms besides Android. But there is some advantage in keeping the rendering in core so you can test in a desktop game window, because you can more rapidly compile and run on the desktop. This library has some tools that make it easy to wrap your rendering code in a class that lets you simulate a live wallpaper on desktop, for testing.

Android studio - Unable to add library from outside folder

I am trying to develop an android library and an app using Android Studio. For this, I need to use the library directly in my app project, so I can modify both the library sources and app sources easily.
I am using versions: Android Studio 3.1.2 and Gradle 4.4
First of all, I have tried both methods described in the documentation, but both methods duplicate the library.
Second, I tried to add the library from outside folder as described here, but I get the error:
Unable to find module with Gradle path ':mytestlibrary3-release' (needed by module 'app'.)
My test structure is like this:
In "Workspace" folder I have the app folder "MyApplication4" and library folder "MyTestLib3" containing the library module "mytestlibrary3" (I attached screens)
The application settings.gradle:
include ':app'
include ':mytestlibrary3-release'
project(':mytestlibrary3-release').projectDir = new File(settingsDir, '../MyTestLib3/mytestlibrary3')
and the application build.gradle:
...
dependencies {
...
implementation project(':mytestlibrary3-release')
}
What am I doing wrong here? My purpose is to use the code directly (similar to Eclipse "Add Project to Build Path" or link src folder to source) or to build and use the library as simple and elegant as possible.

How to use releaseImplementation in a library

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.

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