我通过删除本地目录等清洗整个项目~/.gradle,~/.m2 ~./android并~/workspace/project/.gradle和艇员选拔File -> Invalidate Caches / Restart...Android Studio中.现在执行命令./gradlew会导致以下输出:
usr$ ./gradlew tasks
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Run Code Online (Sandbox Code Playgroud)
不用说,我删了太多,问题是如何再次修复?你有任何想法如何解决这个问题?
我一直在尝试将一个项目导入Android Studio,这就是我被困住的地方,Stack Overflow上有一个类似的问题,但它没有为我的特定错误提供解决方案.
这是我的错误日志:
C:\<some location>\build.gradle
Error:(24, 1) A problem occurred evaluating root project '<project name>'.
> Could not find method android() for arguments [build_4fli1jm76ubcnxesnhqnhie47$_run_closure3@6e71db85] on root project '<project name>'.
Information:BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
Gradle同步消息是:
错误:(24,0)未找到Gradle DSL方法:'android()'可能的原因:
项目'PoojaPeople'可能正在使用不包含该方法的Gradle版本.Gradle设置 构建文件可能缺少Gradle插件.应用Gradle插件
我不太确定这个方法到底在哪里android().如果是位于应用程序build.gradle文件中的那个,我仍然不知道从哪里开始.任何帮助表示赞赏.
我的build.gradle是
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files …Run Code Online (Sandbox Code Playgroud) android build.gradle android-gradle-plugin android-studio-import android-studio-2.0
我在查看所有类似的问题和答案后发布了这个问题。
这是我研究的问题。
也许,您可能想知道这是一个重复的问题,但就我而言,事实并非如此。让我们看看情况如何。首先,这是错误来源的代码片段:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.facebook.react:react-native:+"
}Run Code Online (Sandbox Code Playgroud)
此代码来自文件:node_modules/react-native-geocoder/android/build.gradle
现在让我向您展示出现的错误。
FAILURE: Build failed with an exception.
* Where:
Build file '/Project-root/node_modules/react-native-geocoder/android/build.gradle' line: 19
* What went wrong:
A problem occurred evaluating project ':react-native-geocoder'.
> Could not find method compile() for arguments [directory …Run Code Online (Sandbox Code Playgroud)我有一个hello world全屏android studio 1.5.1应用程序,我添加了gradle/eclipse-mars子项目.除了将settings:'javalib'添加到settings.gradle之外,没有其他文件被修改.添加项目lib依赖项:
project(':app') {
dependencies {
compile project(':javalib') // line 23
}
}
Run Code Online (Sandbox Code Playgroud)
从根构建构建文件并从命令行运行gradle,得到:
其中:构建文件'D:\ AndroidStudioProjects\AndroidMain\build.gradle'行:23
出了什么问题:评估根项目'AndroidMain'时出现问题.
无法在org.grad le.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@46 3ca82f上为参数[project':javalib']找到方法compile().
将java插件添加到根构建文件没有帮助.
我不认为它在错误的地方.
根项目和添加的子项目都有gradle包装器.
任何指针将不胜感激.
谢谢
编辑:为了澄清,根构建文件是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories …Run Code Online (Sandbox Code Playgroud) 我已经得到了错误(类型org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer的配置容器无法获取不明财产“运行”)。当我跟着答案如何使用复制的gradle所有来源罐子,加下面的代码到 build.gradle 并在 IJ IDEA 中运行该任务:
task copySourceJars( type: Copy ) {
def sources = configurations.runtime.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [
group: artifact.moduleVersion.id.group,
name: artifact.moduleVersion.id.name,
version: artifact.moduleVersion.id.version,
classifier: 'sources'
] )
}
from configurations.detachedConfiguration( sources as Dependency[] )
.resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
into file( 'some-directory/' )
}
Run Code Online (Sandbox Code Playgroud)
我对错误进行了网络搜索,但仅在 stackoverflow 上发现了Gradle - 无法获得配置容器的未知属性“scm”,建议在阅读该帖子后添加配置,就像我在阅读该帖子后所做的那样:
configurations {
runtime
}
Run Code Online (Sandbox Code Playgroud)
在任务copySourceJars运行之后,它写了BUILD SUCCESSFUL,但没有文件出现在硬盘驱动器的特定目录中。由于某种原因构建输出未列出copySourceJars:
Executing tasks: [:app:generateDebugSources]
Gradle Daemon started in 1 s 427 ms
> Task :app:preBuild UP-TO-DATE …Run Code Online (Sandbox Code Playgroud) 遇到这个要点:https : //gist.github.com/chemouna/00b10369eb1d5b00401b之后,我注意到它正在使用Google Truth库:https : //google.github.io/truth/。因此,我首先按照build.gradle在Android Studio中的文件中添加库的过程进行操作:
buildscript {
repositories.mavenLocal()
}
dependencies {
testImplementation "com.google.truth:truth:0.40"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我想为我的断言java类的Truth入口点添加静态导入时:
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
Run Code Online (Sandbox Code Playgroud)
我收到错误,该符号Truth无法解析。我试图重建我的项目并实现此处所述的解决方案:导入中未识别的AndroidTestCompile 依赖项,主要运行以下gradle任务:
但问题仍然存在。
有什么帮助吗?
我是否应该在build.gradle文件中实际添加这些行?:
buildscript {
repositories.mavenLocal()
}
Run Code Online (Sandbox Code Playgroud)
如果我已经有这些:
repositories {
mavenCentral()
jcenter()
google()
}
Run Code Online (Sandbox Code Playgroud) 我一直在尝试创建一个文本字段框,如材料设计指南中所述.我无法弄清楚如何实现这一目标.这就是我想要实现的目标.
如果图像不够清晰,我还附上了具有材料设计指南的链接.我只需要创建一个文本字段框,但我无法弄明白.这是材料设计指南页面的链接
https://material.io/guidelines/components/text-fields.html#text-fields-text-field-boxes
还附加我想要创建的文本字段的xml代码.
<android.support.design.widget.TextInputLayout
android:id="@+id/firstNameTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/firstNameTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/firstName"
android:inputType="textPersonName"
tools:ignore="MissingPrefix" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
提前致谢.请帮助.
我正在尝试学习 spark java web 框架。我正在使用 Intellij 并创建了一个新项目,刚刚添加了一个 HelloWorld 类,但是出现了这个错误,
Build file '/Users/mingwang/SourceCodes/spark-example/build.gradle' line: 17
A problem occurred evaluating root project 'spark-example'.
> Could not find method compile() for arguments [com.sparkjava:spark-core:2.9.3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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.
Run Code Online (Sandbox Code Playgroud)
我的 build.gradle 就像
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group 'org.example' …Run Code Online (Sandbox Code Playgroud) 我正在尝试将离子电容器项目的 gradle 更新到版本 7.0.1。我不断收到此错误
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [{name=barcodescanner-release-2.1.5, ext=aar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Run Code Online (Sandbox Code Playgroud)
我搜索了很多来解决这个问题,但所有可能的修复都表明我需要更改“app/build.grade”中的“编译”方法“实现”,但实际上该文件不包含“编译”方法!
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "****"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 10
versionName "1.8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} …Run Code Online (Sandbox Code Playgroud) android ×6
gradle ×5
build.gradle ×1
deprecated ×1
google-truth ×1
gradlew ×1
java ×1
node-modules ×1
react-native ×1
spark-java ×1
subproject ×1
testing ×1
textfield ×1