15

Background

Google has a website for all of the AOSP apps here, which includes its launcher, contacts etc...

The problem

I'd like to know how to import those apps. More specifically, the launcher and the contacts apps (though I'd also like to know about others too).

Thing is, it's not that simple. You can't just import the cloned project and that's it. Even if you use Eclipse (which seems like the official tool used on those repositories, according to the folders hirerchy ) it doesn't work as easily.

What I've found

I've found an old post regarding how to import the launcher (version 4.4.x) , but it's using Eclipse and I think require Linux to build some files.

I've tried to import using Eclipse, but for some reason I couldn't get to use a working "protobuf" library. I've tried to use a jar from here, but it didn't succeed importing it.

There is also a nice third party library that has an imported version of the launcher app, but currently it's a bit behind as it's based on Kitkat (4.4) and not Lollipop (5.0) .

The question

How do you import those projects? Is there an easy way? Would it work even on Windows OS and Android Studio ?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • I don't know about the launcher and contacts applications in particular, but several of the stock AOSP applications can't be built against the Android SDK. They're only meant to be built together with the platform and getting them into Eclipse or Android Studio requires some work. – Magnus Bäck Mar 24 '15 at 06:34
  • I see. I wonder though : how do they built everything? Do they use Android-Studio or Eclipse ? Do they really import everything in this website that I've written (and more) ? it looks like a lot of things to compile... I also wonder if I can submit changes there to be confirmed by them, to improve how anything works. – android developer Mar 24 '15 at 09:38
  • A complete Android platform source code workspace is tens of GBs in size and takes considerable time to build (using GNU make). See https://source.android.com/source/contributing.html for how to contribute. – Magnus Bäck Mar 24 '15 at 10:48
  • @MagnusBäck So each person who want to contribute will need to download this amount of code and resources and compile it (which takes a lot of time probably) ? It will take ages to even add anything (because you need to test it too). How come it's not "fragmented", so that each part is compilable and easy to work on separately ? – android developer Mar 24 '15 at 12:09
  • Probably because it at some point was easier to do it this way, and they so far haven't prioritized the task to unbundle these particular apps. That work has been done with other apps though. – Magnus Bäck Mar 24 '15 at 13:15
  • @MagnusBäck Probably there are other tools involved. I see a lot of weird files there that I don't think Eclipse needs. – android developer Mar 24 '15 at 20:13
  • There is a way to do it in Eclipse. I don't know how to do it anymore but I've seen it done. You can build a version of Android's SDK without the stripped symbols (this comes naturally as a by product of a full AOSP build), and then you can use that library instead of the official SDK, then you should be able to build. – Pwnna Mar 28 '15 at 02:01

3 Answers3

4

How do you import those projects?

You just clone their git repositories. However the only way to compile them will be together will all the AOSP project.

Trying to compile the app without it is impossible because of an ugly mix of:

1.Dependencies with other projects of AOSP

2.Using hidden API's which are not available to a regular app(these apps were designed to be system apps which have additional API's). These APIS don't even exist in the SDK.

3.Using Android.mk system with hacks that can't be used with Gradle or even the eclipse plugin.

Is there an easy way?

No. For the Launcher its few days of work, for the Contacts its easier to start from scratch.

Would it work even on Windows OS and Android Studio ?

Not without a lot of effort.

There is one more thing, the applications you see in Nexus devices are not a result of compiling the code you download from Google's website. Their apps go through many patch cycles and QA while what you will compile result in a very buggy product which will need heavy maintenance.

My suggestion is to look for truly open source applications, and not count on Google's good will.

skoperst
  • 2,259
  • 1
  • 23
  • 35
  • Yes, by "import" I also meant being able to compile it well. Anyway, how come so many launchers out there are based on the one of AOSP ? – android developer Mar 24 '15 at 12:06
  • I can just guess people did work hard and made it standalone app. Launcher specifically is easier then other projects. – skoperst Mar 24 '15 at 12:24
  • 3
    ok, since you've made a lot of effort of writing and trying to help, you get +1, but I would still want to leave this question open. Maybe somebody, some time in the future, will find a way to import those projects easily. – android developer Mar 24 '15 at 21:54
4

Here is another approach. AOSP apps are intended to be "native", First you should think, what does this means? This actually means that they are intended to be compiled via the 'mm' command after doing an envsetup and lunch on your main AOSP directory. Also notice that the Android.mk for each app(found at aosp/packages/apps) compiles the file to store them on the /system/app folder on your final image. So yes, this approach makes it difficult to import to AndroidStudio because this type of compilation lacks AndroidStudio's gradle build system, which actually works in an entirely different way.

Other problems you may encounter: - Since Native AOSP app live on /system in Android and are compiled with odex optimization they may give trouble when trying to install any derived work unless you change the module names, and the app name on the AndroidManifest File.

One simple solution: Simply start a new Android Studio project and import relevant java classes and resources from the aosp to your project. I know this sounds like a "lazy" solution but still, y taking this approach you should make sure to name your app differently (different module name) than the AOSP app so it will not conflict with the native aosp app(or any derived app such as GoogleCamera(which extends from AOSP Camera)). Also this will setup the gradle environment required to normally create Android Apps. Hope this helps.

Jorch914
  • 3,465
  • 2
  • 16
  • 21
  • You have a point, but I still would like to know the shortest and easiest way to do it. – android developer Mar 26 '15 at 11:19
  • In my experience what I'm recommending may not be the shortest, but is the easiest way to do this properly without avoiding any conflicts or workarounds considering the gradle build system. Think of it as just java classes, you may even just import the package as a library and reuse it. Unless your goal is to extend the native app, this is still my recommendatoin. Cheers – Jorch914 Mar 26 '15 at 15:20
  • ok, i will try it again. I still hope there is an easier way to do it. here, take a +1 for trying to help. :) – android developer Mar 28 '15 at 11:47
  • thank you, by the way, have you tried this? http://stackoverflow.com/questions/16727607/can-we-use-android-studio-for-aosp-development. cheers :) – Jorch914 Mar 29 '15 at 17:41
  • I don't think I need/want this link. – android developer Mar 30 '15 at 18:34
0

For Launcher3, you can visit https://android.googlesource.com/platform/packages/apps/Launcher3/+/android-6.0.1_r9 .

The aosp Launcher3 adds build.gradle file now, you could just copy the total directory to your work directory, and change gradlew file mode to let it can execute, and then use ./gradlew clean && ./gradlew build to build the Launcher3. Also you need close the abortOnError of lint in build.grale use

android {
    // Other configuration
    lintOptions {
        abortOnError false
    }
}

Note:Don't change protobuf version in build.gradle, otherwise it may broke the build process.

utzcoz
  • 649
  • 4
  • 15
  • It gives me an error when I open via Android-Studio: Error:Unable to find method 'org.gradle.api.internal.file.DefaultSourceDirectorySet.(Ljava/lang/String;Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;)V'. Possible causes for this unexpected error include:... – android developer Nov 11 '16 at 18:32
  • don't update gradle tools and protobuf tools version in build.gradle and try again. – utzcoz Nov 17 '16 at 04:10
  • I tried again. I didn't update anything. It only asked for a gradle wrapper and I accepted. I got this error:" Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject. Gradle 'Launcher3-5fcaab43e603ceabd1d71ec355c8a0b59aac8cf0.tar' project refresh failed" . I don't understand your explanation of what to do. What do you mean by " change gradlew file mode to let it can execute" ? Change in which way? And, shouldn't the building of the project be done via the IDE ? – android developer Nov 17 '16 at 10:16
  • The android studio can do it. The origin launcher3 repository don't provide gradlew and gradle wrapper file, so I need copy them from my other android studio project. Sometime, it can not execute because of linux's file system, so I say need let gradlew can execute. I try agian, I download the launcher3 code from official repository, and checkout to least android 6.0 commit (android 7.0's launcher3 gradle does not work now), and add gradlew and gradle wrapper, it works fine. If needs, I can upload it to github. – utzcoz Nov 18 '16 at 07:54
  • I have post code to github : https://github.com/jywangkeep/android_packages_apps_launcher3 – utzcoz Nov 18 '16 at 09:44
  • I still don't understand what you did to make it work – android developer Nov 19 '16 at 22:56
  • I just add gradlew and gradle wrapper files in launcher3 root directory, and add `abortOnError` on `build.gradle`, that's all. – utzcoz Nov 20 '16 at 12:28
  • I tried what you wrote: made it import via Android Studio, added the lines you wrote, and yet it still has an issue: "... project refresh failed. Error:Could not determine the class-path for interface com.android.builder.model.NativeAndroidProject. " . I even tried the newest version of the launcher: https://android.googlesource.com/platform/packages/apps/Launcher3/+/android-7.1.0_r7/ – android developer Nov 27 '16 at 07:34
  • I wrote all I got – android developer Jul 14 '17 at 13:02