Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Add Android Studio 2.2+ CMake #20

Merged
merged 2 commits into from
Oct 27, 2016
Merged

Add Android Studio 2.2+ CMake #20

merged 2 commits into from
Oct 27, 2016

Conversation

mickele
Copy link
Contributor

@mickele mickele commented Oct 26, 2016

Since Android Studio 2.2, they're including a CMake dependency in the SDK Manager, but it's not available to install through android update sdk --no-ui --filter [NAME] afaik.

The most updated version can be found at: https://dl.google.com/android/repository/repository2-1.xml // last <remotePackage> node

This is needed for all new CMake build system: https://developer.android.com/ndk/guides/cmake.html

@mickele
Copy link
Contributor Author

mickele commented Oct 26, 2016

This will fix #16 I suppose

@viktorbenei
Copy link
Contributor

Hi,

Thanks a lot! Just a question, wouldn't simply upgrading the NDK version help? This Docker image still installs NDK r12 (https://github.com/bitrise-docker/android-ndk/pull/20/files#diff-3254677a7917c6c01f55212f86c57fbfR17), while the latest now is r13 (https://developer.android.com/ndk/downloads/index.html)

@mickele
Copy link
Contributor Author

mickele commented Oct 27, 2016

Not really, if you don't include the CMake dependency, all projects using NDK together with the new CMake build system will just fail with this message:

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_xxDebugApk'.
   > A problem occurred configuring project ':app'.
      > Failed to find CMake.
        Install from Android Studio under File/Settings/Appearance & Behavior/System Settings/Android SDK/SDK Tools/CMake.
        Expected CMake executable at /Users/xx/Library/Android/sdk/cmake/bin/cmake.

# uncompress
RUN cd /opt/android-cmake-tmp && unzip -q android-cmake.zip -d android-cmake
# move to it's final location
RUN cd /opt/android-cmake-tmp && mv ./android-cmake ${ANDROID_HOME}/cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake have to be in ANDROID_HOME and not in the NDK HOME?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it's at the same level of "platform-tools", "ndk-bundle" and so on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I wonder why it's not part of the Android SDK then.. Well, I guess it's only required for NDK, but then why they chose to put it into the SDK home?..

Anyway, in case of Android it's not always "logical" how things work / where things are ¯_(ツ)_/¯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the same, that's why at first I tried to go only with the apt-get install cmake route but that didn't work out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just tested and the ANDROID_HOME path is where Studio installs cmake, so 👍

only thing now is to rebase this PR, and that's all ;)

RUN cd /opt/android-cmake-tmp && wget -q https://dl.google.com/android/repository/cmake-3.6.3155560-linux-x86_64.zip -O android-cmake.zip
# uncompress
RUN cd /opt/android-cmake-tmp && unzip -q android-cmake.zip -d android-cmake
# move to it's final location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: it's -> its ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! ;)

@viktorbenei
Copy link
Contributor

Can you please rebase this on the current master? Merging the other PR resulted in a minor conflict unfortunately

# uncompress
RUN cd /opt/android-cmake-tmp && unzip -q android-cmake.zip -d android-cmake
# move to its final location
RUN cd /opt/android-cmake-tmp && mv ./android-cmake ${ANDROID_HOME}/cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, shouldn't this be ${ANDROID_HOME}/cmake/3.6.3155560 instead? That's where Android Studio installs it

Copy link
Contributor

@viktorbenei viktorbenei Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also checked the content of the zip and it's not exactly the same as what you get if you install CMake from Android Studio, but that's probably not an issue (it's the same cmake version)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZIP tree:

tree . -L 3
.
├── android.toolchain.cmake
├── bin
│   ├── cmake
│   ├── cpack
│   ├── ctest
│   └── ninja
├── doc
│   └── cmake-3.6
│       ├── Copyright.txt
│       ├── cmcompress
│       ├── cmcurl
│       ├── cmlibarchive
│       ├── cmliblzma
│       ├── cmsys
│       └── cmzlib
├── share
│   ├── aclocal
│   │   └── cmake.m4
│   └── cmake-3.6
│       ├── Help
│       ├── Modules
│       ├── Templates
│       ├── completions
│       ├── editors
│       └── include
└── source.properties

Android Studio installed cmake tree:

tree . -L 3
.
├── android.toolchain.cmake
├── bin
│   ├── ccmake
│   ├── cmake
│   ├── cmakexbuild
│   ├── cpack
│   ├── ctest
│   └── ninja
├── doc
│   └── cmake-3.6
│       ├── Copyright.txt
│       ├── cmcompress
│       ├── cmcurl
│       ├── cmlibarchive
│       ├── cmliblzma
│       ├── cmsys
│       └── cmzlib
├── package.xml
├── share
│   ├── aclocal
│   │   └── cmake.m4
│   └── cmake-3.6
│       ├── Help
│       ├── Modules
│       ├── Templates
│       ├── completions
│       ├── editors
│       └── include
└── source.properties

e.g. cmakexbuild is missing from the ZIP

Copy link
Contributor Author

@mickele mickele Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, true, I tried without the version number just because of the error message they showed me when I tried to build without CMake:

Expected CMake executable at /Users/xx/Library/Android/sdk/cmake/bin/cmake.

It works outside the version folder, I need to recheck to see if it builds using the Android Studio folder config, probably it will

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I tested with this changes:

-RUN cd /opt/android-cmake-tmp && mv ./android-cmake ${ANDROID_HOME}/cmake
+RUN cd /opt/android-cmake-tmp && mkdir ${ANDROID_HOME}/cmake/ && mv ./android-cmake ${ANDROID_HOME}/cmake/3.6.3155560
---
-ENV PATH ${PATH}:${ANDROID_HOME}/cmake/bin
+ENV PATH ${PATH}:${ANDROID_HOME}/cmake/3.6.3155560/bin

It finds the binaries:

# which cmake
/opt/android-sdk-linux/cmake/3.6.3155560/bin/cmake

But it doesn't compile. It gives the same error as before:

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_qaDebugApk'.
   > Failed to find CMake.
     Install from Android Studio under File/Settings/Appearance & Behavior/System Settings/Android SDK/SDK Tools/CMake.
     Expected CMake executable at /opt/android-sdk-linux/cmake/bin/cmake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... that's quite strange, given that's not the place where the Android Studio installs cmake, but I guess we can have this as a "first version", and if required change it in the future

@viktorbenei viktorbenei merged commit 90b08b8 into bitrise-io:master Oct 27, 2016
@viktorbenei
Copy link
Contributor

viktorbenei commented Oct 27, 2016

Thanks for the PRs, you're a true hero!! ;)

Schedule: the next alpha images will be created in ~12 hours, tested as usual, and then, if everything's OK deployed (as non alpha images) on Saturday

So, by Sunday you should have this on bitrise.io ;)

@viktorbenei
Copy link
Contributor

viktorbenei commented Feb 2, 2017

@mickele can you check this discussion bitrise-io/build.issues#33 (comment) ? It seems that installing a default cmake can actually cause issues.

It seems that the latest gradle / android tools can now auto install the required cmake version when you run e.g ./gradlew assemble, just like it does with other dependencies (build tools, sdk version, etc.)

Do you have a sample project we could use to test whether removing the default installed cmake would cause Failed to find CMake. again? In the sample project we used (https://github.com/viktorbenei/testBitriseAndroidNDK) if we rm -rf ${ANDROID_HOME}/cmake before any android/gradle command (right after Git Clone), it still works - gradlew assemble will download the right cmake version for the build.

From the sample's build log:

...
./gradlew "--build-file" "build.gradle" "assemble" "--stacktrace"
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
...

Checking the license for package CMake 3.6.3155560 in /opt/android-sdk-linux/licenses
License for package CMake 3.6.3155560 accepted.
Preparing "Install CMake 3.6.3155560".
"Install CMake 3.6.3155560" ready.
Finishing "Install CMake 3.6.3155560"
Installing CMake 3.6.3155560 in /opt/android-sdk-linux/cmake/3.6.3155560
"Install CMake 3.6.3155560" complete.

...

:app:packageRelease
:app:assembleRelease
:app:assemble

BUILD SUCCESSFUL

@viktorbenei
Copy link
Contributor

Another question is whether cmake is required to be in PATH or not, not sure if we should keep https://github.com/bitrise-docker/android-ndk/pull/20/files#diff-3254677a7917c6c01f55212f86c57fbfR41 or that's not required either.

@viktorbenei
Copy link
Contributor

We've made a test where PATH did not include the cmake bin dir, and it worked that way as well.

@viktorbenei
Copy link
Contributor

Proposed PR to remove the preinstalled cmake: #38

We plan to merge and ship this next week, unless there's a use case against this change.

@mickele
Copy link
Contributor Author

mickele commented Feb 2, 2017

@viktorbenei oh, actually I moved recently and I don't have my dev environment prepared yet nor access to my old projects that were using cmake.

But I think you can safely remove if there's another solution now.

@viktorbenei
Copy link
Contributor

I think we'll remove it then, and if that would cause issues related to this change, we can add it again with a reverse commit anyway ;)

Thanks for the info and for your PR/work @mickele !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants