异常内容
运行一个Flutter项目时提示:
Launching lib\main.dart on 21091116C in debug mode…
Warning: Observed package id ‘build-tools;30.0.3’ in inconsistent location ‘D:\Android\android-sdk\build-tools\30.0.3-2’ (Expected ‘D:\Android\android-sdk\build-tools\30.0.3’)
Warning: Already observed package id ‘build-tools;30.0.3’ in ‘D:\Android\android-sdk\build-tools\30.0.3’. Skipping duplicate at ‘D:\Android\android-sdk\build-tools\30.0.3-2’
Warning: Observed package id ‘build-tools;30.0.3’ in inconsistent location ‘D:\Android\android-sdk\build-tools\30.0.3-3’ (Expected ‘D:\Android\android-sdk\build-tools\30.0.3’)
Warning: Already observed package id ‘build-tools;30.0.3’ in ‘D:\Android\android-sdk\build-tools\30.0.3’. Skipping duplicate at ‘D:\Android\android-sdk\build-tools\30.0.3-3’
Warning: Observed package id ‘build-tools;30.0.3’ in inconsistent location ‘D:\Android\android-sdk\build-tools\30.0.3-2’ (Expected ‘D:\Android\android-sdk\build-tools\30.0.3’)
Warning: Already observed package id ‘build-tools;30.0.3’ in ‘D:\Android\android-sdk\build-tools\30.0.3’. Skipping duplicate at ‘D:\Android\android-sdk\build-tools\30.0.3-2’
Warning: Observed package id ‘build-tools;30.0.3’ in inconsistent location ‘D:\Android\android-sdk\build-tools\30.0.3-3’ (Expected ‘D:\Android\android-sdk\build-tools\30.0.3’)
Warning: Already observed package id ‘build-tools;30.0.3’ in ‘D:\Android\android-sdk\build-tools\30.0.3’. Skipping duplicate at ‘D:\Android\android-sdk\build-tools\30.0.3-3’
Warning: Failed to download any source lists!
Warning: IO exception while downloading manifest:
Warning: IO exception while downloading manifest:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:579)
at java.base/sun.nio.ch.Net.connect(Net.java:579)
at java.base/sun.nio.ch.Net.connect(Net.java:568)
at java.base/sun.nio.ch.Net.connect(Net.java:568)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
at java.base/java.net.Socket.connect(Socket.java:633)
at java.base/java.net.Socket.connect(Socket.java:633)
at java.base/java.net.Socket.connect(Socket.java:583)
at java.base/java.net.Socket.connect(Socket.java:583)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531)
at java.base/sun.net.www.http.HttpClient$1.run(HttpClient.java:590)
at java.base/sun.net.www.http.HttpClient$1.run(HttpClient.java:590)
at java.base/sun.net.www.http.HttpClient$1.run(HttpClient.java:588)
at java.base/sun.net.www.http.HttpClient1. r u n ( H t t p C l i e n t . j a v a : 588 ) a t j a v a . b a s e / j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( A c c e s s C o n t r o l l e r . j a v a : 569 ) a t j a v a . b a s e / j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( A c c e s s C o n t r o l l e r . j a v a : 569 ) a t j a v a . b a s e / s u n . n e t . w w w . h t t p . H t t p C l i e n t . p r i v i l e g e d O p e n S e r v e r ( H t t p C l i e n t . j a v a : 587 ) a t j a v a . b a s e / s u n . n e t . w w w . h t t p . H t t p C l i e n t . o p e n S e r v e r ( H t t p C l i e n t . j a v a : 631 ) a t j a v a . b a s e / s u n . n e t . w w w . h t t p . H t t p C l i e n t . p r i v i l e g e d O p e n S e r v e r ( H t t p C l i e n t . j a v a : 587 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s C l i e n t . < i n i t > ( H t t p s C l i e n t . j a v a : 266 ) a t j a v a . b a s e / s u n . n e t . w w w . h t t p . H t t p C l i e n t . o p e n S e r v e r ( H t t p C l i e n t . j a v a : 631 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s C l i e n t . N e w ( H t t p s C l i e n t . j a v a : 380 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s C l i e n t . < i n i t > ( H t t p s C l i e n t . j a v a : 266 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . g e t N e w H t t p C l i e n t ( A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . j a v a : 193 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s C l i e n t . N e w ( H t t p s C l i e n t . j a v a : 380 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p . H t t p U R L C o n n e c t i o n . p l a i n C o n n e c t 0 ( H t t p U R L C o n n e c t i o n . j a v a : 1287 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . g e t N e w H t t p C l i e n t ( A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . j a v a : 193 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p . H t t p U R L C o n n e c t i o n . p l a i n C o n n e c t ( H t t p U R L C o n n e c t i o n . j a v a : 1128 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p . H t t p U R L C o n n e c t i o n . p l a i n C o n n e c t 0 ( H t t p U R L C o n n e c t i o n . j a v a : 1287 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . c o n n e c t ( A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . j a v a : 179 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p . H t t p U R L C o n n e c t i o n . p l a i n C o n n e c t ( H t t p U R L C o n n e c t i o n . j a v a : 1128 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s U R L C o n n e c t i o n I m p l . c o n n e c t ( H t t p s U R L C o n n e c t i o n I m p l . j a v a : 142 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . c o n n e c t ( A b s t r a c t D e l e g a t e H t t p s U R L C o n n e c t i o n . j a v a : 179 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . o p e n U r l ( D o w n l o a d C a c h e . j a v a : 245 ) a t j a v a . b a s e / s u n . n e t . w w w . p r o t o c o l . h t t p s . H t t p s U R L C o n n e c t i o n I m p l . c o n n e c t ( H t t p s U R L C o n n e c t i o n I m p l . j a v a : 142 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . d o w n l o a d A n d C a c h e ( D o w n l o a d C a c h e . j a v a : 622 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . o p e n U r l ( D o w n l o a d C a c h e . j a v a : 245 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . o p e n C a c h e d U r l ( D o w n l o a d C a c h e . j a v a : 453 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . d o w n l o a d A n d C a c h e ( D o w n l o a d C a c h e . j a v a : 622 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . L e g a c y D o w n l o a d e r . d o w n l o a d A n d S t r e a m ( L e g a c y D o w n l o a d e r . j a v a : 65 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . r e m o t e . i n t e r n a l . D o w n l o a d C a c h e . o p e n C a c h e d U r l ( D o w n l o a d C a c h e . j a v a : 453 ) a t c o m . a n d r o i d . r e p o s i t o r y . i m p l . d o w n l o a d e r . L o c a l F i l e A w a r e D o w n l o a d e r . d o w n l o a d A n d S t r e a m ( L o c a l F i l e A w a r e D o w n l o a d e r . j a v a : 51 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . l e g a c y . L e g a c y D o w n l o a d e r . d o w n l o a d A n d S t r e a m ( L e g a c y D o w n l o a d e r . j a v a : 65 ) a t c o m . a n d r o i d . r e p o s i t o r y . i m p l . m a n a g e r . R e m o t e R e p o L o a d e r I m p l . l a m b d a 1.run(HttpClient.java:588) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) at java.base/sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:587) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:631) at java.base/sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:587) at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:631) at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380) at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193) at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1287) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1287) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.openUrl(DownloadCache.java:245) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.downloadAndCache(DownloadCache.java:622) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.openUrl(DownloadCache.java:245) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.openCachedUrl(DownloadCache.java:453) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.downloadAndCache(DownloadCache.java:622) at com.android.sdklib.repository.legacy.LegacyDownloader.downloadAndStream(LegacyDownloader.java:65) at com.android.sdklib.repository.legacy.remote.internal.DownloadCache.openCachedUrl(DownloadCache.java:453) at com.android.repository.impl.downloader.LocalFileAwareDownloader.downloadAndStream(LocalFileAwareDownloader.java:51) at com.android.sdklib.repository.legacy.LegacyDownloader.downloadAndStream(LegacyDownloader.java:65) at com.android.repository.impl.manager.RemoteRepoLoaderImpl.lambda1.run(HttpClient.java:588)atjava.base/java.security.AccessController.doPrivileged(AccessController.java:569)atjava.base/java.security.AccessController.doPrivileged(AccessController.java:569)atjava.base/sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:587)atjava.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:631)atjava.base/sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:587)atjava.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)atjava.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:631)atjava.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380)atjava.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)atjava.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)atjava.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380)atjava.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1287)atjava.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)atjava.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128)atjava.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1287)atjava.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)atjava.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128)atjava.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142)atjava.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.openUrl(DownloadCache.java:245)atjava.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.downloadAndCache(DownloadCache.java:622)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.openUrl(DownloadCache.java:245)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.openCachedUrl(DownloadCache.java:453)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.downloadAndCache(DownloadCache.java:622)atcom.android.sdklib.repository.legacy.LegacyDownloader.downloadAndStream(LegacyDownloader.java:65)atcom.android.sdklib.repository.legacy.remote.internal.DownloadCache.openCachedUrl(DownloadCache.java:453)atcom.android.repository.impl.downloader.LocalFileAwareDownloader.downloadAndStream(LocalFileAwareDownloader.java:51)atcom.android.sdklib.repository.legacy.LegacyDownloader.downloadAndStream(LegacyDownloader.java:65)atcom.android.repository.impl.manager.RemoteRepoLoaderImpl.lambdafetchPackages0 ( R e m o t e R e p o L o a d e r I m p l . j a v a : 138 ) a t c o m . a n d r o i d . r e p o s i t o r y . i m p l . d o w n l o a d e r . L o c a l F i l e A w a r e D o w n l o a d e r . d o w n l o a d A n d S t r e a m ( L o c a l F i l e A w a r e D o w n l o a d e r . j a v a : 51 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . E x e c u t o r s 0(RemoteRepoLoaderImpl.java:138) at com.android.repository.impl.downloader.LocalFileAwareDownloader.downloadAndStream(LocalFileAwareDownloader.java:51) at java.base/java.util.concurrent.Executors0(RemoteRepoLoaderImpl.java:138)atcom.android.repository.impl.downloader.LocalFileAwareDownloader.downloadAndStream(LocalFileAwareDownloader.java:51)atjava.base/java.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:539)
at com.android.repository.impl.manager.RemoteRepoLoaderImpl.lambda$fetchPackages0 ( R e m o t e R e p o L o a d e r I m p l . j a v a : 138 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . F u t u r e T a s k . r u n ( F u t u r e T a s k . j a v a : 264 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . E x e c u t o r s 0(RemoteRepoLoaderImpl.java:138) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.Executors0(RemoteRepoLoaderImpl.java:138)atjava.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)atjava.base/java.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutorW o r k e r . r u n ( T h r e a d P o o l E x e c u t o r . j a v a : 635 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1136 ) a t j a v a . b a s e / j a v a . l a n g . T h r e a d . r u n ( T h r e a d . j a v a : 833 ) a t j a v a . b a s e / j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.lang.Thread.run(Thread.java:833) at java.base/java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:635)atjava.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)atjava.base/java.lang.Thread.run(Thread.java:833)atjava.base/java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Warning: Still waiting for package manifests to be fetched remotely.
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring project ‘:rive_common’.
NDK not configured. Download it with SDK manager. Preferred NDK version is ‘21.4.7075529’.
- Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
- Get more help at https://help.gradle.org
BUILD FAILED in 2s
Running Gradle task ‘assembleDebug’… 3.3s
Exception: Gradle task assembleDebug failed with exit code 1
信息显示“NDK未配置。用SDK管理器下载它。首选的NDK版本是“21.4.7075529”。”
这个错误的主要原因是Android NDK (Native Development Kit) 没有配置。NDK 是一套工具,允许你使用 C 和 C++ 等语言来编写 Android 应用的部分。
可以按照以下步骤来解决这个问题:
- 打开 Android Studio。
- 点击顶部菜单的 “Tools”,然后选择 “SDK Manager”。
- 在弹出的窗口中,点击 “SDK Tools” 标签。
- 在列表中找到 “NDK (Side by side)”,并勾选它。如果已经勾选,那么请确保其版本与错误信息中的版本一致。
- 点击 “OK” 或 “Apply” 来下载并安装 NDK。
完成以上步骤后,可以正常运行了。
关于 NDK
NDK,全称为 Native Development Kit,是 Android 的一个工具集,它允许开发者使用 C 和 C++ 等本地语言来编写 Android 应用的部分代码。
NDK 的主要用途包括:
- 性能关键部分的编程:对于一些计算密集型的应用,如游戏或者图像处理,使用本地语言(C/C++)可以提供更高的执行效率。
- 复用代码库:如果你有大量的 C/C++ 代码库,并且想在 Android 应用中复用这些代码,那么 NDK 就非常有用。
- 调用本地 API:有些系统级别的 API 只能通过本地语言调用,这时候就需要使用 NDK。
不过使用 NDK 需要处理更多的跨平台兼容性问题,而且本地代码的调试也比 Java 或 Kotlin 更困难。此外,本地代码也不能自动享受到 Java 语言的一些优点,如垃圾回收和内存管理。因此,除非有明确的需求,否则一般不建议在 Android 应用中使用 NDK。