android - 无法解决:常见的Android Studio
问题描述
我最近在 gradle build/sync 上收到此错误消息:
当我单击“打开文件”时,它会切换到build.gradle (App)窗口。
我在stackoverflow上没有得到任何解决方案。请检查代码并让我知道问题所在。
我将衷心感谢您的帮助。
build.gradle (项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
google()
}
dependencies {
/*compile('javax.inject:javax.inject:1',
'com.google.dagger:dagger:2.7',
'de.greenrobot:eventbus:2.2.1',
'io.reactivex:rxjava:1.2.0',
'io.reactivex:rxandroid:1.2.1')
compile files('libs/publisher-sdk-android-5.1.0.jar')*/
}
}
build.gradle(应用程序)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.appname"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
//multiDexEnabled = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}*/
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
// Vungle SDK
//implementation 'com.github.vungle:vungle-android-sdk:6.2.5'
// Optional Google Play Services - Location and Basement
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
//Replace it with Google Analytics?
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'org.jsoup:jsoup:1.8.3'
implementation 'com.github.simbiose:Encryption:2.0.1'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
解决方案
使用这些
先检查
转到设置/首选项 > 构建、执行、部署选项 > 即时运行并取消选中所有三个框。
1 . 升级 Gradle 服务 URL:
项目 > Gradle > 包装器 > gradle-wrapper.properties
更改网址
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
至
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
(在这里找到最新的distributionUrl gradle插件版本:http ://services.gradle.org/distributions
**确保使用 gradle-x.xx-all.zip )
2 . 删除您的构建文件夹
运行项目时,将自动创建 build 文件夹
3 . 转到菜单中的构建选项>清理项目,构建项目
它应该在没有即时运行的情况下工作。
推荐阅读
- python - 程序只读取 csv 文件的第一行
- struct - 为什么我不能多次调用变异函数?
- reactjs - 如何在枢轴对象上获取前景色
- invoice - 将日期字段添加到发票odoo12的问题
- xml - 如何使用 XSLT 从另一个 XML 文档提供属性值?
- javascript - 如果道具发生变化,反应重新评估 useRef
- excel - 在 VBA 过滤器中从 dd mm 切换到 mm dd 的日期
- java - 正确实现所有相等对象的属性
- forms - 如何根据选择字段的 onChange 事件在 vuelidate 中启用所需的验证
- java - 如何在 Java 中进行此 CURL 调用?