我的应用程序build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.marcus.exceltest"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'org.apache.poi:poi:4.1.1'
implementation 'org.apache.poi:poiooxml:4.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
}
我的Gradle build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的Gradle.properties
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
错误:
错误:未找到Gradle DSL方法:“ implementation()” 可能的原因: 项目``Exceltest''可能正在使用不包含该方法的Android Gradle插件版本(例如,在1.1.0中添加了``testCompile'')。 将插件升级到3.5.2版并同步项目
项目“ Exceltest”可能正在使用不包含该方法的Gradle版本。 打开Gradle包装器文件
构建文件可能缺少Gradle插件。 应用Gradle插件
事件日志: 18:27 Gradle同步失败:在类型org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象上找不到参数[androidx.appcompat:appcompat:1.1.0]的方法Implementation()。 (950毫秒)
18:27 NDK分辨率结果:项目设置:Gradle模型版本= 5.4.1,NDK版本为UNKNOWN
18:28运行“ Exceltest”时出错:Gradle项目同步失败。请修复您的项目,然后重试。
在升级到Android Studio v3.5.2之前,一切正常,尝试了AS提供的所有建议,但是我在尝试手动更新(gradle升级和工具升级)方面遇到了困难。我是AS的新手,我看过以前的答案,但它们与许多旧版本有关,或者我的版本中不存在文件系统。请有人帮忙吗?
答案 0 :(得分:0)
您在错误的位置import React from "react";
import styled from 'styled-components'
const Box = styled.div`
position: relative;
display: flex;
flex-wrap: wrap;
flex-direction: column;
${({ invalid }) => invalid && `
transform: rotate(0deg);
transition: all 0.5s ease-in-out;
`}
margin: 0 10px 0 0;
`
const VCell = styled.div`
display: flex;
flex: 0 0 auto;
flex-direction: row;
`
const Cell = styled.div`
flex: 0 0 auto;
`
const Label = styled.div`
display:flex;
height: 100%;
font-weight: 700;
align-items: flex-end;
`
const HoverTooltip = styled.span`
display: none;
position: absolute;
height: auto;
width: 200px;
bottom: 30px;
right: -30px;
text-align: center;
padding: 5px;
z-index: 1;
color: #fff;
&:after {
content: " ";
position: absolute;
bottom: -5px; /* At the top of the tooltip */
left: 50%;
margin-bottom: -5px;
border-width: 5px;
border-style: solid;
border-color: black transparent transparent transparent;
}
`
const Input = styled.input`
margin: 3px 10px 0 10px !important;
height: auto !important;
outline: 0;
border: 0;
max-width: 100px;
padding: 2px 0;
border-bottom: 1px solid ${palette.darkGrey};
`
const HoverTooltipWrap = styled.span`
position: relative;
&:hover ${HoverTooltip} {
display: block;
}
`
const Tooltip = styled.div`
max-width: 80%;
`
const Units = styled.span`
display:flex;
height: 100%;
align-items: flex-end;
`
const Bohrfrei = styled.span`
position: absolute;
top: 4px;
left: 210px;
height: 20px;
width: 20px;
border-radius: 50%;
color: #fff;
background: #000;
text-align: center;
${media.large`
top: 4px;
right: -30px;
`}
`
const BohrfreiTooltip = styled.span`
display: none;
position: absolute;
top: -176px;
right: calc(50% - 30px);
height: auto;
width: auto;
border: 1px solid ${palette.orange};
text-align: center;
padding: 5px;
z-index: 1;
color: #fff;
background: #fff;
&:after {
content: " ";
position: absolute;
top: 100%;
left: 84%;
margin-top: 1px;
border-width: 6px;
border-style: solid;
border-color: ${palette.orange} transparent transparent transparent;
}
${media.large`
bottom: -150px;
right: -450px;
top: auto;
&:after {
content: " ";
position: absolute;
top: 50%;
right: 100%;
left: -12px;
margin-top: -5px;
border-width: 6px;
border-style: solid;
border-color: transparent ${palette.orange} transparent transparent;
}
`}
${Bohrfrei}:hover & {
display: block;
}
`
const Img = styled.img`
width: 213px;
height: 152px;
${media.large`
width: 426px;
height: 304px;
`}
`
const utilizeFocus = () => {
const ref = React.createRef()
const setFocus = () => {ref.current && ref.current.focus()}
return {setFocus, ref}
}
class DimensionBox extends React.Component {
constructor(props){
super(props)
this.inputFocus = utilizeFocus()
this.breite = utilizeFocus()
}
handleChange = (event) => {
this.props.onChange(event.target.value);
}
render() {
return (
<Box
invalid={!this.props.isValid}
type="number"
>
<VCell>
{/* <input ref={this.breite.ref}/> */}
<Cell>{this.props.priceFetching && console.log('fetching')}
<Label>{this.props.label}</Label>
</Cell>
<Cell>
<HoverTooltipWrap>
<Input
type="text"
innerRef={this.breite.ref}
ref={this.breite.ref}
id={(this.props.label === 'Breite' && 'Breite' || this.props.label === 'Höhe' && 'Höhe' || undefined)}
name={(this.props.label === 'Breite' && 'Breite' || this.props.label === 'Höhe' && 'Höhe' || undefined)}
value={this.props.value || '' }
onChange={this.handleChange}
onBlur={this.handleBlur}
disabled={this.props.priceFetching}
/>
{(this.props.label === 'Breite' || this.props.label === 'Breite 1' || this.props.label === 'Breite 2' || this.props.label === 'Breite 3' ||
this.props.label === 'Höhe' || this.props.label === 'Höhe 1' || this.props.label === 'Höhe 2') &&
<HoverTooltip>
{(this.props.label === 'Breite' || this.props.label === 'Breite 1' || this.props.label === 'Breite 2' || this.props.label === 'Breite 3') &&
<span>
{`Minimale Breite: ${this.props.minWidth}mm / Maximale Breite: ${this.props.maxWidth}mm`}
<br />
{`Bitte beachten Sie, dass bei maximaler Breite die maximale Höhe nicht höher sein darf ${this.props.maxHeightBei}mm `}
</span>
}
{(this.props.label === 'Höhe' || this.props.label === 'Höhe 1' || this.props.label === 'Höhe 2' )&&
<span>
{`Minimale Höhe: ${this.props.minHeight}mm / Maximale Höhe: ${this.props.maxHeight}mm`}
<br />
{`Bitte beachten Sie, dass bei maximaler Höhe die maximale Breite nicht breiter sein darf ${this.props.maxWidthBei}mm `}
</span>
}
{/* {this.props.label === 'Höhe 2' && `Minimale Höhe: ${this.props.minHeight}mm / Maximale Höhe: ${this.props.maxHeight}mm`} */}
{/* {this.props.label === 'Breite 3' && `Minimale Breite: ${this.props.minWidthSmallTop}mm / Maximale Breite: ${this.props.maxWidthSmallTop}mm`} */}
</HoverTooltip>
}
</HoverTooltipWrap>
</Cell>
<Cell>
<Units>mm</Units>
<button onClick={this.breite.setFocus}>
FOCUS breite
</button>
</Cell>
{this.props.label === 'FF* Höhe' &&
<div>
<Bohrfrei>?
<BohrfreiTooltip><Img src={bohrfrei}/></BohrfreiTooltip>
</Bohrfrei>
</div>
}
</VCell>
<VCell> <Tooltip>{this.props.tooltip}</Tooltip></VCell>
</Box>
);
}
};
export default DimensionBox;
上写了这行,从gradle类路径下的gradle implementation androidx.appcompat:appcompat:1.1.0
删除了这一行
答案 1 :(得分:0)
项目的build.gradle文件中有错误。看起来应该像这样
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 2 :(得分:0)
一切似乎都很好,但是, 1 。您迁移到Androidx的某些库,有些没有迁移,所以我要求您将项目的所有库迁移到androidx。 2 。从您的项目级别gradle文件中删除实施行,或将其移至App级别gradle文件。