-
-
[推荐]在macOS上安装android-sdk时jdk版本不对的解决办法
-
发表于: 2017-11-26 22:16 6409
-
环境:macOS 10.12.6
操作:
$ java --version java 9 Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode) $ brew cask install android-sdk ==> Caveats We will install android-sdk-tools, platform-tools, and build-tools for you. You can control android sdk packages via the sdkmanager command. You may want to add to your profile: 'export ANDROID_SDK_ROOT=/usr/local/share/android-sdk' This operation may take up to 10 minutes depending on your internet connection. Please, be patient. ==> Satisfying dependencies ==> Downloading 451K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6V1L8q4)9J5k6h3N6G2L8$3N6D9k6g2)9J5k6h3y4G2L8g2)9J5c8X3q4F1k6s2u0G2K9h3c8Q4x3V1k6J5k6i4m8G2M7$3W2@1L8%4u0&6i4K6u0r3M7$3c8C8i4K6u0V1N6r3!0G2L8s2y4Q4x3X3c8V1j5i4u0%4K9h3&6Q4x3X3b7K6z5o6f1&6x3K6V1%4i4K6u0W2P5X3W2H3 Already downloaded: /Users/tomasnovella/Library/Caches/Homebrew/Cask/android-sdk--3859397,26.0.1.zip ==> Verifying checksum for Cask android-sdk ==> Installing Cask android-sdk ==> Exception in thread "main" ==> java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema ==> at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156) ==> at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75) ==> at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81) ==> at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117) ==> at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93) ==> Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema ==> at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ==> at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ==> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ==> ... 5 more Error: Command failed to execute! ==> Failed command: /usr/local/Caskroom/android-sdk/3859397,26.0.1/tools/bin/sdkmanager tools platform-tools build-tools;26.0.1 ==> Standard Output of failed command: ==> Standard Error of failed command: Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156) at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75) at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81) at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117)
即使尝试自己下载,也会出现这个java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
的问题,搜索中文网站无果之后,在万能的StackOverFlow找到了答案,原来是*Java9太新了,要回到Java8*就好了
解决步骤:
- brew cask uninstall java # uninstall java9
- brew tap caskroom/versions
- brew cask install java8 # install java8
- touch ~/.android/repositories.cfg # without this file, error will occur on next step
- brew cask install android-sdk
通过此步骤操作成功!
成功安装各种sdk
$ sh sdkmanager "platform-tools" "platforms;android-25" License android-sdk-license: --------------------------------------- Terms and Conditions This is the Android Software Development Kit License Agreement 1. Introduction 1.1 The Android Software Development Kit (re ... ... 14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction. November 20, 2015 --------------------------------------- Accept? (y/N): y done roysuedeiMac:bin roysue$
adb
和fastboot
安装成功!
$ ./adb Android Debug Bridge version 1.0.39 Revision 3db08f2c6889-android Installed as /Users/roysue/Downloads/platform-tools/./adb global options: -a listen on all network interfaces, not just localhost -d use USB device (error if multiple devices connected) -e use TCP/IP device (error if multiple TCP/IP devices available) -s SERIAL use device with given serial number (overrides $ANDROID_SERIAL) -p PRODUCT name or path ('angler'/'out/target/product/angler'); default $ANDROID_PRODUCT_OUT -H name of adb server host [default=localhost] -P port of adb server [default=5037] -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037] general commands: devices [-l] list connected devices (-l for long output)
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
赞赏
雪币:
留言: