如何读取android sdkmanager输出,以便我可以安装一个包?

时间:2017-05-29 11:43:02

标签: android

android sdkmanager工具有一种几乎列出可用包的方法,如下所示:

try {

                    Class.forName("oracle.jdbc.OracleDriver");

                } catch (ClassNotFoundException e) {

                    System.out.println("Where is your Oracle JDBC Driver?");
                    e.printStackTrace();
                    return;

                }

                System.out.println("Oracle JDBC Driver Registered!");

                Connection connection = null;

                try {


                    connection = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=abcd.efg)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OW_DEF)))","user","pwd#");
                } catch (SQLException e) {

                    System.out.println("Connection Failed! Check output console");
                    e.printStackTrace();
                    return;

                }

                if (connection != null) {
                    System.out.println("You made it, take control your database now!");
                } else {
                    System.out.println("Failed to make connection!");
                }

我想了解如何实际读取输出,以便从命令行安装其中一个软件包。

1 个答案:

答案 0 :(得分:1)

您需要使用--verbose标志来获取完整的包名称:

sdkmanager --list --verbose

输出将如下所示:

system-images;android-25;android-wear;armeabi-v7a
    Description:        Android Wear ARM EABI v7a System Image
    Version:            3
    Dependencies:
        patcher;v4

system-images;android-25;android-wear;x86
    Description:        Android Wear Intel x86 Atom System Image
    Version:            3
    Dependencies:
        patcher;v4

system-images;android-25;google_apis;arm64-v8a
    Description:        Google APIs ARM 64 v8a System Image
    Version:            4

system-images;android-25;google_apis;armeabi-v7a
    Description:        Google APIs ARM EABI v7a System Image
    Version:            4

system-images;android-25;google_apis;x86
    Description:        Google APIs Intel x86 Atom System Image
    Version:            4

system-images;android-25;google_apis;x86_64
    Description:        Google APIs Intel x86 Atom_64 System Image
    Version:            4