Skip to content

Commit 2d1937f

Browse files
author
zhangbin
committed
Solve the error when building Android Studio project on Windows.
1 parent 115c42b commit 2d1937f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plugins/plugin_compile/build_android.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,16 @@ def _update_project_properties(self, folder_path, target_str):
223223

224224
def _write_local_properties(self, folder_path):
225225
local_porps_path = os.path.join(folder_path, 'local.properties')
226+
sdk_dir = self.sdk_root
227+
ndk_dir = cocos.check_environment_variable('NDK_ROOT')
228+
if cocos.os_is_win32():
229+
# On Windows, the path should be like:
230+
# sdk.dir = C:\\path\\android-sdk
231+
sdk_dir = sdk_dir.replace('\\', '\\\\')
232+
ndk_dir = ndk_dir.replace('\\', '\\\\')
226233
lines = [
227-
'sdk.dir=%s\n' % self.sdk_root,
228-
'ndk.dir=%s\n' % cocos.check_environment_variable('NDK_ROOT')
234+
'sdk.dir=%s\n' % sdk_dir,
235+
'ndk.dir=%s\n' % ndk_dir
229236
]
230237
f = open(local_porps_path, 'w')
231238
f.writelines(lines)

0 commit comments

Comments
 (0)