SDK Manager无法启动

首先cmd切换到android-sdk-windows\tools\lib,找到find_java.bat

打开回显:rem @echo off,再运行find_java.bat,若输出的set java_exe=同jdk安装路径不符,则需要检查环境变量JAVA_HOME和PATH中java.exe是否设置正确,其逻辑在于android/platform/sdk/find_java/src/source/find_java_lib.cpp中的函数findJavaInEnvPath:

// Search java.exe in the environment
int findJavaInEnvPath(CPath *outJavaPath, bool isJdk, int minVersion) {
    SetLastError(0);

    const char* envPath = getenv("JAVA_HOME");
    if (envPath != NULL) {
        CPath p(envPath);

        if (!isJdk || isJdkPath(p)) {
            int v = checkBinPath(&p);
            if (v >= minVersion) {
                if (gIsDebug) {
                    fprintf(stderr, "Java %d found via JAVA_HOME: %s\n", v, p.cstr());
                }
                *outJavaPath = p;
                // As an optimization for runtime, if we find a suitable java
                // version in JAVA_HOME we won‘t waste time looking at the PATH.
                return v;
            }
        }
    }

    int currVersion = 0;
    envPath = getenv("PATH");
    if (!envPath) return currVersion;

    // Otherwise look at the entries in the current path.
    // If we find more than one, keep the one with the highest version.

    CArray<CString> *paths = CString(envPath).split(‘;‘);
    for(int i = 0; i < paths->size(); i++) {
        CPath p((*paths)[i].cstr());

        if (isJdk && !isJdkPath(p)) {
            continue;
        }

        int v = checkPath(&p);
        if (v >= minVersion && v > currVersion) {
            if (gIsDebug) {
                fprintf(stderr, "Java %d found via env PATH: %s\n", v, p.cstr());
            }

            currVersion = v;
            *outJavaPath = p;
        }
    }

    delete paths;
    return currVersion;
}

可看到其逻辑是在环境变量中先查找JAVA_HOME,若没有则再查找PATH中最高版本的java.exe,当然java.exe的版本最小为6.1。

若环境变量中java.exe设置无误,则检查批处理find_java.bat是否有误,这是因为SDK Manager.exe源码android/platform/sdk/sdklauncher/src/source/sdklauncher.c显示其是调用android-sdk-windows\tools\android.bat

int sdk_launcher() {
    int                   result = 0;
    STARTUPINFO           startup;
    PROCESS_INFORMATION   pinfo;
    CHAR                  program_dir[MAX_PATH];
    int                   ret, pos;

    ZeroMemory(&pinfo, sizeof(pinfo));

    ZeroMemory(&startup, sizeof(startup));
    startup.cb = sizeof(startup);
    startup.dwFlags     = STARTF_USESHOWWINDOW;
    startup.wShowWindow = SW_HIDE|SW_MINIMIZE;

    /* get path of current program, to switch dirs here when executing the command. */
    ret = GetModuleFileName(NULL, program_dir, sizeof(program_dir));
    if (ret == 0) {
        display_error("Failed to get program‘s filename:");
        result = 1;
    } else {
        /* Remove the last segment to keep only the directory. */
        pos = ret - 1;
        while (pos > 0 && program_dir[pos] != ‘\\‘) {
            --pos;
        }
        program_dir[pos] = 0;
    }

    if (!result) {
        dprintf("Program dir: %s\n", program_dir);

        // SDK Manager.exe is installed by the Windows Installer just below
        // the tools directory and needs to access tools\android.bat
        ret = CreateProcess(
                NULL,                                       /* program path */
                "tools\\android.bat sdk",                   /* command-line */
                NULL,                  /* process handle is not inheritable */
                NULL,                   /* thread handle is not inheritable */
                TRUE,                          /* yes, inherit some handles */
                CREATE_NO_WINDOW,                /* we don‘t want a console */
                NULL,                     /* use parent‘s environment block */
                program_dir,             /* use parent‘s starting directory */
                &startup,                 /* startup info, i.e. std handles */
                &pinfo);

        if (!ret) {
            dprintf("CreateProcess returned %d\n", ret);

            // In the ADT bundle, SDK Manager.exe is located in the sdk folder
            // and needs to access sdk\tools\android.bat
            ret = CreateProcess(
                    NULL,                                   /* program path */
                    "sdk\\tools\\android.bat sdk",          /* command-line */
                    NULL,              /* process handle is not inheritable */
                    NULL,               /* thread handle is not inheritable */
                    TRUE,                      /* yes, inherit some handles */
                    CREATE_NO_WINDOW,            /* we don‘t want a console */
                    NULL,                 /* use parent‘s environment block */
                    program_dir,         /* use parent‘s starting directory */
                    &startup,             /* startup info, i.e. std handles */
                    &pinfo);
        }

        dprintf("CreateProcess returned %d\n", ret);

        if (!ret) {
            display_error("Failed to execute tools\\android.bat:");
            result = 1;
        }
    }

    dprintf("Cleanup.\n");

    return result;
}
时间: 07-08

SDK Manager无法启动的相关文章

Android sdk manager无法启动之swt.jar文件没有指定

此问题的出现其实和swt.jar这个文件一点关系都没有,最终笔者通过百度之在http://www.aichengxu.com/view/39361找到解决办法. 现复制其内容如下: android sdk 无法运行或者报 "ANDROID_SWT"错误,有需要的朋友可以参考下. 安装 android sdk 之后,一般都在eclise里面用.有一次发现直接运行 sdk manager.exe打不开了,也不报错.一闪就没了. 因为没有错误信息,只好一直凑活着用eclipse启动sdk m

sdk manager 创建的虚拟机启动的时候总是在Android字样解决

一直显示Android字样,只需要删除目录下的snapshots.img 找到sdk的目录下的\tools\lib\emulator,然后删除上面的文件snapshots.img即可,我的sdk路径是下面的,所以进入这里杀出它就好了 D:\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\tools\lib\emulatorsdk manager 创建的虚拟机启动的时候总是在Android字样解决,布布扣,bu

Android Studio 1.5启动出现“SDK Manager: failed to install”问题的解决

问题描述 Android Studio 1.5是当前最新Android手机应用开发平台,下载bundle版安装后,启动Studio后出现“SDK Manager: failed to install”问题.详细信息如下: Android SDK was installed to C:\Users\jack\AppData\Local\Android\sdk Installing Archives:  Preparing to install archives  Installing SDK Pl

Android SDK Manager和AVD Manager使用

Android SDK Manager和AVD Manager使用(win7_64bit下测试) 目录 1.概述 2.本文用到的工具 3.安卓开发基础工具包下载 4.Android SDK Manager使用 5.AVD Manager使用 6.注意事项 7.相关博文(AndroidStudio.IDEA.Eclipse安卓环境配置) >>看不清的图片可在新标签打开查看大图 1.概述 顾名思义,Android SDK Manager就是一个Android软件开发工具包管理器,就像一个桥梁,连通

Android SDK Manager国内无法更新的解决方案

现在由于GWF,google基本和咱们说咱见了,就给现在在做Android  或者想学习Android 的朋友带来了诸多的不便,最简单的就是Android SDK Manager 你无法更新了. 现在这里有一个解决方案,如下. 1.启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 2.在『Android SDK Manager - Settings』窗口中,在「

Android SDK Manager不能显示所有包的解决办法

试试这个,能解决国内访问Google服务器的困难 启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 在『Android SDK Manager - Settings』窗口中,在「HTTP Proxy Server」和「HTTP Proxy Port」输入框 内填入mirrors.neusoft.edu.cn和80,并且选中「Forcehttps://... so

Android SDK Manager 更新

解决国内访问Google服务器的困难: 1.启动 Android SDK Manager : 2.打开主界面,依次选择「Tools」.「Options…」,弹出『Android SDK Manager – Settings』窗口: 3.在『Android SDK Manager – Settings』窗口中,在「HTTP Proxy Server」和「HTTP Proxy Port」输入框内填入mirrors.neusoft.edu.cn和80,并且选中「Force https://… sour

Eclipse配置安卓开发环境(解决SDK manager下载慢问题)

Android新手在eclipse搭建安卓开发环境基本都会遇到Android SDK manager下载慢,ADT下载慢的问题,本文将带大家完整的安装一遍开发环境 工具:eclipse     SDK    ADT 第一步: 启动eclipse,依次点击菜单栏的 Help  ->Install new software,如下图,再点击 add,Name一栏随便起个名字,location中找到你的SD压缩文件的位置,点击 OK 全选Select All ,一定要不要勾选Contact all  u

Android SDK Manager 更新代理配置

Android SDK Manager 更新代理配置 启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 在『Android SDK Manager - Settings』窗口中,在「HTTP Proxy Server」和「HTTP Proxy Port」输入框内填入 mirrors.neusoft.edu.cn 和 80,并且选中「Force https://.