-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ndk-build with Android Studio. #15676
Conversation
|
Thanks @chaoren . Can i debug C++ codes after apply this patch? |
Yes. Please try it out and file bugs if you run into any.
I can't give you any specific dates here, but stable is usually about a month or so behind canary. |
|
Thanks, i will have a try. |
|
[ci rebuild] |
|
@chaoren How to test it? I just downloaded Android Studio 2.2, and click |
|
Oh, i tested cpp-empty-test, and i found you didn't modify it. I will try by creating a new project. |
|
@chaoren I'm getting the following error on windows: Any ideas? |
|
@minggo Ah, my apologies, I'll change the tests as well. @TheCodez currently, you'll need to install this for it to work on Windows: https://www.microsoft.com/en-us/download/details.aspx?id=48145 |
|
@chaoren Thanks, but that didn't fix the problem. [EDIT] I created a new project and now I'm getting a different error: |
|
@TheCodez are you opening the test projects or creating a new project from template and opening that? Please provide the steps you performed before reaching that error. |
|
@chaoren I just created a new project using cocos console, and opened the I've attached my log, hope it's somehow useful. [EDIT] When doing |
|
I met the error when importing a new project: Steps to reproduce:
I uses latests cocos2d-x codes and apply this PR. And my OS is Mac OS X 10.11.4. The full log file is Edit: i installed Android Studio 2.2 preview 1 and Android Studio 2.0. |
|
Could you please make sure that these SDK components are installed and up to date? SDK Platforms -> Android 5.1 (Lollipop) 22 We'll need to change that message to something more useful. |
|
It seems LLDB 2.2 is missing. I will try to install it. |
|
@chaoren My computer has Cmake, but Android Studio can not find it and ask me to install it. And i can not find a way to set Cmake path. |
|
The CMake integration requires the custom CMake from the SDK, so the CMake on your computer would not work. When this feature stabilizes, we'll hopefully upstream our changes to CMake, but whether the ~20MB of space is worth the additional complexity is debatable. |
|
@TheCodez could you please make sure that you're using the latest NDK? |
|
@chaoren Ok, i downloaded the cmake and needed components. And it can compile the codes. But i can not see the log, for example, which cpp file is compiled, and what's the compiling flags and so on as i can before using |
Yes, that is the expected behavior right now. We could change the compiling to be more verbose, but we'll have to look at whether the extra output would significantly slow down compilation. |
|
@chaoren The app crashed when i clicked |
|
@minggo does clicking just run (without debug) work? Are you running against a physical device or an emulator? |
|
No. It can not run no matter debug or not, and no matter select MyCppGame or MyCppGame-native. I tested on Android device(Sangsung S4 Zoom, Android 4.2.2). |
|
And i found there is a strange log |
|
That's a normal message when attaching the debugger. When you say "crashed", does it just look like it's hanging, or is it opening the app then immediately closing? Could you please provide the logcat as it crashes? |
|
It closed immediately, the logcat is And i found the output |
|
I installed Android Studio 2.2 Preview 1 on OSX 10.11.4, checked out your branch, then created a new project. But I couldn't sync the gradle file with the project. The IDE simply got an exception. Here's the Error Logs |
|
@cezheng you get that error when the NDK isn't present, please make sure |
|
I'm using AS 2.2.3 and can see all .cpp files. Problem is with extra .h files. I have a file named "Definitions.h", it is in android.mk file, but studio isn't showing it. I had no other issues and moved all my cocos2d-x projects to android studio. Also: some people report having this error: "Error: Configuration with name 'default' not found.". I don't know what causes this, because it's not happening on my device. |
|
@piotrros you can see cocos2d-x .cpp files? |
|
@minggo it depends on build.gradle. When I was using cocos2d-x bundled in project I could see all cocos2d-x files. Now I use precompiled library so I naturally don't see them. |
|
I mean with this PR, i can not see cocos2d-x files. Does it mean this PR has some problem in build.gradle? |
|
It should be fine. I've modified build.gradle to my own needs. Using precompiled libraries makes app compile in seconds.. By the way it's not fine to use all abiFilters (abiFilters 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a'), apk will be huge. I'm personally using armeabi-v7a and can debug c++ code on all my devices. |
|
@piotrros yep, we should only build one target. I will merge this PR in 3.15 if possible because we have to modify cocos command to adapt it too. And i am not familiar with build.gradle grammar. I have to learn more about it. |
|
2.3 is in beta here: http://tools.android.com/download/studio/canary/latest
…On Wed, Feb 15, 2017 at 10:27 PM, minggo ***@***.***> wrote:
then you can not see the cocos2d-x cpp files in Android Studio
@jomof <https://github.com/jomof> this issue still exists in Android
Studio 2.2.3. Is it fixed in Android Studio 2.3? And i can not find where
to download 2.3.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9Lm3vJTRO0ujVfmbIFS-vVhd0UI7ks5rc-xagaJpZM4Ihn7u>
.
|
|
@jomof i will merge this PR though i can not view the cocos2d-x cpp files in Android Studio. Can you view the cocos2d-x cpp files in Android Studio? |
|
@minggo, I verified your steps of 11/15 show cpp files with an earlier 2.3
beta. I'll recheck with the most recent beta. Monday is a Google holiday,
but I'll check Tuesday
…On Sun, Feb 19, 2017 at 7:15 PM, minggo ***@***.***> wrote:
Merged #15676 <#15676>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9NTv7_I41uNPxU04Fs8T9jfYx99Eks5reQU2gaJpZM4Ihn7u>
.
|
|
@jomof thanks. I haven't tried 2.3 since it is not stable. |
I am doing lua project setting for Android Studio as mentioned above. I want to include |
|
I have to do like this to delete unneeded folders, but is there any other way to exclude them? |
|
I don't directly know how to solve that problem but Gradle's FileCollection
is typically how you build sets of files with exclusions.
…On Mon, Feb 20, 2017 at 1:11 AM, minggo ***@***.***> wrote:
I have to do like this to delete unneeded folders, but is there any other
way to exclude them?
android.applicationVariants.all { variant ->
def rmassets = task("delete${variant.name}Assets", type: Delete) {
delete "${buildDir}/intermediates/assets/${variant.dirName}/project"
delete "${buildDir}/intermediates/assets/${variant.dirName}/simulator"
}
variant.mergeAssets.finalizedBy rmassets
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9Bwo8YeDMFLkT4GJWYjO9XWL78Ygks5reVjTgaJpZM4Ihn7u>
.
|
|
How to exclude resources? I tried |
* Use ndk-build integration in Android Studio. * Update build.gradle * Update build.gradle * Update build.gradle
…futurePRs * commit 'eca39ba7aa7105133c012f53a8c3a7a71793f72c': fixed cocos2d#17413: [Android] AudioEngine::play2d may still wait 2 seconds if preload is too fast. (cocos2d#17414) Fix various typos in comments and strings (cocos2d#17410) Fix variable name typo in Sprite3DTest.js (cocos2d#17409) Update the reference of submodule cocos2d-console. (cocos2d#17407) Fix minor typos in tests (cocos2d#17404) Typo fix: Rename `MutiTouchTest` to `MultiTouchTest` (cocos2d#17399) Fix minor typos in UI test cases (cocos2d#17400) fixed cocos2d#17397: Updates CMakeList.txt for win32 audio module (cocos2d#17401) Update the reference of submodule web. (cocos2d#17396) Update the reference of submodule web. (cocos2d#17393) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#17392) Update the spine runtime of JS. (cocos2d#17391) [ci skip]make all tests and template support Android Studio (cocos2d#17389) Use ndk-build with Android Studio. (cocos2d#15676) [WebSocket] Adds support for getting url and server selected protocol (cocos2d#17381) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically Refine editbox for issue 17346 --merge some member variables into EditBoxCommon (cocos2d#17361) # Conflicts: # tools/cocos2d-console
|
@jomof I updated Android Studio to 2.3, can not see cocos2d-x c++ source codes. |
|
That's not good to hear, are you following the steps from 11/15/16 in this
thread? (Aside from merge the PR)
…On Mon, Mar 13, 2017 at 3:22 AM, minggo ***@***.***> wrote:
@jomof <https://github.com/jomof> I updated Android Studio to 2.3, can
not see cocos2d-x c++ source codes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9P19e3hOmDvkL6ft7h2EVQlmZByoks5rlRj2gaJpZM4Ihn7u>
.
|
|
I tested with latest codes which includes this PR. You can have a try. And the steps is the same as 11/15/16 in this thread. |
|
I'm having trouble just building the latest project with Gradle. Downstream
this would cause the files not to show up in Android Studio, but am I doing
this wrong?
$ git clone https://github.com/cocos2d/cocos2d-x.git
$ cd cocos2d-x/tests/cpp-empty-test/proj.android-studio
$ ./gradlew assemble
../../../../cocos/./Android.mk:312: *** Android NDK: Aborting. . Stop.
:CppEmptyTest:generateJsonModelDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CppEmptyTest:generateJsonModelDebug'.
Build command failed.
Error while executing process
/usr/local/google/home/jomof/Android/Sdk/ndk-bundle/ndk-build with
arguments {NDK_PROJECT_PATH=null
APP_BUILD_SCRIPT=/usr/local/google/home/jomof/projects/cocos2d-x/tests/cpp-empty-test/proj.android-studio/app/jni/Android.mk
NDK_APPLICATION_MK=/usr/local/google/home/jomof/projects/cocos2d-x/tests/cpp-empty-test/proj.android-studio/app/jni/Application.mk
APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-9
NDK_OUT=/usr/local/google/home/jomof/projects/cocos2d-x/tests/cpp-empty-test/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj
NDK_LIBS_OUT=/usr/local/google/home/jomof/projects/cocos2d-x/tests/cpp-empty-test/proj.android-studio/app/build/intermediates/ndkBuild/debug/lib
NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-13
NDK_MODULE_PATH=../../../..:../../../../cocos:../../../../external -j12
APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
Android NDK:
/usr/local/google/home/jomof/Android/Sdk/ndk-bundle/sources/android/cpufeatures/Android.mk:
Cannot find module with tag 'freetype2/prebuilt/android' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly
defined ?
Android NDK: The following directories were searched:
Android NDK: ../../../.
./cocos/./Android.mk:312: *** Android NDK: Aborting. . Stop.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
BUILD FAILED
…On Mon, Mar 13, 2017 at 6:33 PM, minggo ***@***.***> wrote:
I tested with latest codes which includes this PR. You can have a try. And
the steps is the same as 11/15/16 in this thread.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9MfoeffWD2vuKu5GC6x2hg0MWt79ks5rle5hgaJpZM4Ihn7u>
.
|
|
After updating to latest gradle version and build tool version. The issue is fixed. Thanks. |
|
@jomof Did the issue with the path lengths on Windows get resolved? The latest version of AS works perfectly on macOS but when trying to compile on Windows I get path length errors. When setting APP_SHORT_COMMANDS and LOCAL_SHORT_COMMANDS to true in my build.gradle if I run gradle in debug it shows that after I assign them to true they get assigned back to false. |
|
Hi David,
At this point I think all the known Windows path length issues are resolved
so, depending on your environment, your issue may be something I haven't
seen before. Could you open a bug at b.android.com?
Regarding APP_SHORT_COMMANDS and LOCAL_SHORT_COMMANDS. We call ndk-build
twice:
(1) The first time is with -nB to create a build script that we analyze for
metadata about the build to give to Android Studio. This is the where you
see us setting these flags to false. Gnu make should not be accessing the
filesystem during this phase so it should be safe with respect to path
lengths. You can see the exact command we use for this by opening
ndk_build_command.txt. The metadata we produce is next to this file in
android_gradle_build.json.
(2) Later, during the build phase, we call ndk-build again without
resetting those flags. You can see the exact build command we will use by
opening android_gradle_build.json in an editor and looking at
libraries.{target}.buildCommand in the JSON. You should see only your use
of xxx_SHORT_COMMANDS there.
I'm sorry you still have path issues on Windows. I'll fix it if it is
possible to do so. Please provide as much information as you can in the bug
and CC my email (jomof@google.com).
Thanks!
Jomo
…On Thu, Mar 23, 2017 at 3:36 AM, David Hodgkinson ***@***.***> wrote:
@jomof <https://github.com/jomof> Did the issue with the path lengths on
Windows get resolved? The latest version of AS works perfectly on macOS but
when trying to compile on Windows I get path length errors. When setting
APP_SHORT_COMMANDS and LOCAL_SHORT_COMMANDS to true in my build.gradle if I
run gradle in debug it shows that after I assign them to true they get
assigned back to false.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15676 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6z9AoCFyX70RgZ6bq8cnp6Mq7YlAcFks5roksQgaJpZM4Ihn7u>
.
|
|
Hi all, could you please discuss Android Studio issue in the forum? I already created a ticket. And i will lock this thread since there are too many conversations to open this page. |


This feature depends on the latest canary preview of Android Studio. You might want to hold off on this pull request until the feature stabilizes.