How to build a AOSP project in Android Studio - android

I have imported AOSP code into Android Studio, on building it I am getting some internal errors but Run, Debug buttons are disabled.
The errors I am getting are:
Can anyone please help me how to resolve this error and to compile AOSP into Android Studio.
Also can anyone please help to how to convert this project into a Gradle project?

AOSP used a special format of makefile to build the whole project. If you insist build it on the IDE, you should write a plugin to index the whole makefile on your own.
Focus on something more meaningful. Review and modify the code in IDE, build it in shell, save your time.

To browse and debug AOSP use Intellij IDEA (close to Android Studio) or Eclipse.
AOSP source contains a tool to generate configuration for these two IDE called IDEGen.
IDEGen automatically generates Android IDE configurations for IntelliJ IDEA
and Eclipse. Your IDE should be able to compile everything in a reasonable
amount of time with no errors.
IDEGen README
To debug AOSP Java code take a look at this article (even though it is for Android Studio, configuration is the same for InteliJ IDEA).

Related

Unable to select JNI build variant after upgrading Android Studio to version 3.3

I have a Java Android project that includes JNI code written in C.
I often need to debug into the native code and before upgrading Android Studio to version 3.3 it was working.
Now in my project view I don't have any code in my cpp folder. I have confirmed that all of the C libraries are in the folder on my HDD. The CMAKE file is also missing from the project view but is also in the correct place on my HDD.
I have not changed any code from my source control since upgrading.
I am using
'com.android.tools.build:gradle:3.3.0'.
In the Build Variants section next to my JNI module I just have five dashes instead of the debug/production options.
I have uninstalled and reinstalled android studio too.
Is it possible after upgrading I need to add something to my configuration to correct including CMAKE?
I had the same issue, just figured it out. In AndroidStudio 3.3.1, they changed things around a bit I guess. Now you have to link your NDK build to the app you are building it as part of.
This is documented at: https://developer.android.com/studio/projects/gradle-external-native-builds
The section, "Use the Android Studio UI" is what you want.

Android studio 3 c++ file full of errors but compilation is ok

I am using Android studio 3 to develop Android application that contains c++ code that are compiled using cmake and NDK, the compilation is ok and the app runs correctly, but when I try to edit cpp file, the inline compiler shows a lot of errors, all standard header files are missing, this is very annoying as I cannot know if I make any compilation error until I run the app, I am not using any special configuration in cmake or in cradle file, any suggestion to fix the problem?
CLion (the C++ IDE that Android Studio is based on) does not have a perfect C++ parser. I believe there's a fix for the most common issue (not properly handling SFINAE) coming Soon.
Found a solution:
Close Android Studio
In command-line, delete the .idea folder in your project's root folder.
Open Android Studio, invalidate caches and restart.
Open AS again, sync gradle.
If the above steps don't work, try setting your gradle version to 3.3 (if it's not that already), and try the above steps again.

Is there any way to Know the Project is build in Eclipse or Android Studio?

I Would like to know is there any way to know the project is build in Eclipse or Android Studio.Let's say I have one project how can i know this is build in Eclipse or Android Studio.
Detail Description :
I Download one apk form Play Store and I get the source code like below image format.
Any Help be Appreciated. I Search lot of thing but doesn't work me.
The project from your screenshot is built in Android Studio. The highlighted .iml file is an IntelliJ IDEA project file and Android Studio is based on IntelliJ IDEA. Moreover it looks like a Gradle project - there is a gradle folder and gradlew script, which is usually another sign of using Android Studio.

Writing a Gradle for a previous Project

I just started an android project for school, and I have to edit an android application that was built by previous students. I was given source files and apk but no gradle.
I imported into Android Studio and tried to run the build when I saw that I couldn't. I have looked up documentation online for the past 4 days and have so far come up with nothing other than downloading the gradle-2.7 files and running:
build gradle
in my computers shell.
Is there an easy way to build a gradle? Perhaps some tools or such? Or will I have to go through the files and write all the gradles myself?
Android Studio uses a Gradle wrapper to fully integrate the Android plugin for Gradle. You can build your Android apps from within Android Studio and from the command line on your machine or on machines where Android Studio is not installed.
Android studio comes bundled with gradle and in the screenshot I can see gradel folder, gradlew and gradlew.bat and build.gradle files. So (hopefully) all you need to take care is build.gradle files.
I would strongly suggest you to go through link
If you have time go through this course

Android Studio 0.4.3 Eclipse project without gradle

Prior to this version it seemed easy to open an eclipse project as-is in Android Studio without any conversion. I prefer the Android Studio environment, but am working on a project that uses eclipse as the main IDE. I'd rather not have to download the eclipse bundle just for this one project.
Is there any way to open an eclipse project as-is, without conversion to the gradle build system, in Android Studio 0.4.3?
EDIT:
It appears that if you use Android Studio's download from source control feature, it'll let you open the project that way. But what if I already have the source downloaded? I don't want to remove it just to redownload it again. It seems like this option has disappeared from the main 'import' wizard.
We're strongly encouraging users to move toward the Gradle build system, and we're in the slow process of making that the only way to create new projects in Android Studio -- you're seeing this now on importing Eclipse-based projects. We'd like to replace all other build systems in use with Gradle, including Ant and the Eclipse internal builder, though the latter two are farther out on the roadmap.
If your ultimate goal is to move to Android Studio, then you might want to reconsider and just set up a Gradle build file. You don't have to adopt the Gradle-style multimodule project structure (which the current Eclipse importer imposes upon you by making a copy of your project); you can rework your build.gradle file to use the Eclipse-structured project in-place. You can get a good start on this if from Eclipse you use the feature to export your project to Gradle build files. It will set up the project in that fashion, though that feature in ADT is a little out of date and you'll need to update the version of the Android Gradle plugin in the build file and the Gradle version in the wrapper that it outputs.
I think this may actually solve your problem. IntelliJ or Android Studio have never been able to use the Eclipse project directly -- they've always imported the Eclipse project and converted to an IntelliJ-style project, and if you later change the Eclipse project, you'll need to re-import into IntellilJ-land. I'm guessing your real desire is to use the Eclipse project in Android Studio without having it make a copy and converting into its preferred directory structure. (By the way, we'll eventually improve Eclipse-to-Gradle import to lift this restriction).
Once you have the Gradle build file in place, you can use it when working with the project in Android Studio, and you'll still have the Eclipse project files when working with it in Eclipse. The big drawback is that you'll have to keep them in sync as you change dependencies and project structure, but hopefully that doesn't happen too often. Even if you weren't using Gradle, you'd still need to keep both projects in sync anyway, so Gradle isn't costing you anything there.
Having said all that, it doesn't directly answer your question, which is how to use the your project without Gradle.
Once you have an IntelliJ-built project, you can open it in Android Studio and use it normally without migrating to Gradle (though I think it does show you a popup when opening the project recommending you do so; you can ignore that). What you need to do is to get that initial IntelliJ project, and once you have it, check all the .iml files into source control -- those .iml files contain all the project information. To get those files, you'll need to import the Eclipse project either in IntelliJ CE, or in Android Studio prior to 0.4.0. Then you'll have your .iml files -- hang on to them.
I'll point out that if you're using Gradle as your build system, we recommend that you don't check those .iml files into source control. There, the build.gradle files are the source of truth for project structure; the fact that Android Studio creates .iml files at all is an implementation detail that reflects that internally Android Studio is still treating this project as an import instead of deriving structure from the Gradle files directly (and we resynchronize state when we know we need to). But saving those .iml files into source control or modifying them directly will lead to confusion or loss of any changes you make there when it resynchronizes.
I think you should give a try to Intellij Idea with ADT Plugin instead of Android Studio, if such requirements are there. Intellij IDEA will support both type of Android projects.
What If I want to move to Android Studio completely sometime?
There is nothing new in Android Studio it is just an IDE based on Intellij IDEA. You can easily switch between Intellij IDE and AS anytime. The only thing is to learn in AS is the new gradle build system. IDE related most of the features are there in Intellij IDE as well.
If you want to move Android Studio start using gradle Build System. That is only the main power of new Tools.
As per your question you don't wanna move your project in gradle then you can have both IDE together like Intellij IDEA at place of Eclipse and Android Studio as well. Msot of the Developer including me having Eclipse along with Android Studio.
EDIT :
I found a workaround to import Eclipse project in Android Studio but I will not recommend you to do this
Look at my answer here
Not Use Gradle In Android Studio

Categories

Resources