运行程序报错

<span style="background-color:var(--highlight-bg)"><span style="color:var(--highlight-color)"><code class="language-vhdl">* What went wrong:
A problem occurred configuring root project <span style="color:var(--highlight-variable)">'danits</span>'.
> Could <span style="color:var(--highlight-keyword)">not</span> resolve <span style="color:var(--highlight-keyword)">all</span> files <span style="color:var(--highlight-keyword)">for</span> <span style="color:var(--highlight-keyword)">configuration</span> ':classpath'.
   > Could <span style="color:var(--highlight-keyword)">not</span> resolve com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span>.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span>
         project : > com.android.<span style="color:var(--highlight-keyword)">library</span>:com.android.<span style="color:var(--highlight-keyword)">library</span>.gradle.plugin:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span>
      > No matching variant <span style="color:var(--highlight-keyword)">of</span> com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span> was found. The consumer was configured <span style="color:var(--highlight-keyword)">to</span> find a runtime <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">library</span> compatible <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">8</span>, packaged as a jar, <span style="color:var(--highlight-keyword)">and</span> its dependencies declared externally, as well as <span style="color:var(--highlight-keyword)">attribute</span> <span style="color:var(--highlight-variable)">'org</span>.gradle.plugin.api-version' <span style="color:var(--highlight-keyword)">with</span> value '<span style="color:var(--highlight-namespace)">7.5</span>.<span style="color:var(--highlight-namespace)">1</span>' but:
          - Variant <span style="color:var(--highlight-variable)">'apiElements</span>' capability com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span> declares a <span style="color:var(--highlight-keyword)">library</span>, packaged as a jar, <span style="color:var(--highlight-keyword)">and</span> its dependencies declared externally:
              - Incompatible because this <span style="color:var(--highlight-keyword)">component</span> declares an API <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">component</span> compatible <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">11</span> <span style="color:var(--highlight-keyword)">and</span> the consumer needed a runtime <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">component</span> compatible <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">8</span>
              - Other compatible <span style="color:var(--highlight-keyword)">attribute</span>:
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about org.gradle.plugin.api-version (required '<span style="color:var(--highlight-namespace)">7.5</span>.<span style="color:var(--highlight-namespace)">1</span>')
          - Variant <span style="color:var(--highlight-variable)">'javadocElements</span>' capability com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span> declares a runtime <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">component</span>, <span style="color:var(--highlight-keyword)">and</span> its dependencies declared externally:
              - Incompatible because this <span style="color:var(--highlight-keyword)">component</span> declares documentation <span style="color:var(--highlight-keyword)">and</span> the consumer needed a <span style="color:var(--highlight-keyword)">library</span>
              - Other compatible attributes:
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about its target Java version (required compatibility <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">8</span>)
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about its elements (required them packaged as a jar)
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about org.gradle.plugin.api-version (required '<span style="color:var(--highlight-namespace)">7.5</span>.<span style="color:var(--highlight-namespace)">1</span>')
          - Variant <span style="color:var(--highlight-variable)">'runtimeElements</span>' capability com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span> declares a runtime <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">library</span>, packaged as a jar, <span style="color:var(--highlight-keyword)">and</span> its dependencies declared externally:
              - Incompatible because this <span style="color:var(--highlight-keyword)">component</span> declares a <span style="color:var(--highlight-keyword)">component</span> compatible <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">11</span> <span style="color:var(--highlight-keyword)">and</span> the consumer needed a <span style="color:var(--highlight-keyword)">component</span> compatible <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">8</span>
              - Other compatible <span style="color:var(--highlight-keyword)">attribute</span>:
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about org.gradle.plugin.api-version (required '<span style="color:var(--highlight-namespace)">7.5</span>.<span style="color:var(--highlight-namespace)">1</span>')
          - Variant <span style="color:var(--highlight-variable)">'sourcesElements</span>' capability com.android.tools.build:gradle:<span style="color:var(--highlight-namespace)">8.0</span>.<span style="color:var(--highlight-namespace)">1</span> declares a runtime <span style="color:var(--highlight-keyword)">of</span> a <span style="color:var(--highlight-keyword)">component</span>, <span style="color:var(--highlight-keyword)">and</span> its dependencies declared externally:
              - Incompatible because this <span style="color:var(--highlight-keyword)">component</span> declares documentation <span style="color:var(--highlight-keyword)">and</span> the consumer needed a <span style="color:var(--highlight-keyword)">library</span>
              - Other compatible attributes:
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about its target Java version (required compatibility <span style="color:var(--highlight-keyword)">with</span> Java <span style="color:var(--highlight-namespace)">8</span>)
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about its elements (required them packaged as a jar)
                  - Doesn<span style="color:var(--highlight-variable)">'t</span> say anything about org.gradle.plugin.api-version (required '<span style="color:var(--highlight-namespace)">7.5</span>.<span style="color:var(--highlight-namespace)">1</span>')</code></span></span>

 我的解决方案:

1.File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

再次同步Gradle

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐