Android Studio无法运行项目
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Studio无法运行项目相关的知识,希望对你有一定的参考价值。
我正在尝试运行长时间的旧项目。突然我无法运行它。
这是build.gradle
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.1.3"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
// For MobFox
maven {
url "https://jitpack.io"
}
// For AppBrain SDK
maven {
url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
}
}
}
这是gradle-wrapper.properties
文件:
#Sun Nov 12 11:49:59 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
org.gradle.jvmargs=-Xmx4608M
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
我收到此错误:
Gradle sync failed: Could not find gradle.jar (com.android.tools.build:gradle:3.0.0).
Searched in the following locations:https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
[当我更改google()
和jcenter()
之间的顺序时,此错误消失了,但现在出现此错误:
error: cannot access zzbfm
class file for com.google.android.gms.internal.zzbfm not found
关于如何解决此问题的任何想法?我宁愿不升级Gradle版本,因为这是一个复杂的项目,我需要在不做大量更改的情况下尽快上传更新。
编辑
这是应用程序build.gradle
文件:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 26
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
debuggable true
buildConfigField "boolean", "CRASH_LOGGING", "true"
applicationIdSuffix ".dev"
}
release {
debuggable false
buildConfigField "boolean", "CRASH_LOGGING", "true"
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
flavorDimensions "regular"
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
implementation "com.android.support:support-compat:26.1.0"
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile 'org.apache.commons:commons-lang3:3.6'
compile 'joda-time:joda-time:2.9.9'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
// UI & VIEWS
compile 'com.tuyenmonkey:mkloader:1.4.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.github.mmin18:realtimeblurview:1.1.0'
compile 'com.github.PhilJay:ValueBar:v1.0.2'
// IMAGE HANDLING
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
// NETWORK HANDLING
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//RETORFIT
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
// FABRIC
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
// ADS
compile 'com.flurry.android:analytics:8.2.0@aar'
compile 'com.appbrain:appbrain-sdk:14.60@aar'
compile(name: 'android-ad-sdk', ext: 'aar')
compile(name: 'SOMAAndroid-9.1.5-release', ext: 'aar')
compile 'com.applovin:applovin-sdk:+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
samsungDebugCompile files('libs/sdk-v1.0.0.jar')
samsungDebugCompile files('libs/motion-v2.2.2.jar')
samsungReleaseCompile files('libs/sdk-v1.0.0.jar')
samsungReleaseCompile files('libs/motion-v2.2.2.jar')
//debug DB
debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
答案
只需进入文件菜单,然后单击使缓存无效并重新启动android studio。
然后从构建菜单进行清理,重建和制作项目。
另一答案
您不能混合版本<= 12和版本> = 15的Firebase库。
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
最简单的解决方法是将所有这些升级到版本16或更高版本:
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
所有这些版本均来自Android文档的setting up Firebase,因此请确保在那里检查最新更新。
背景:在版本12和更低版本中,项目中所有Firebase(和Play服务)库的版本必须完全相同。在以后的版本15中,您可以混合使用版本。但是无法在单个项目中混合<= 12和> = 15个库。
以上是关于Android Studio无法运行项目的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio - 如何从片段中停止 handler.postDelayed?
片段中的TextView在Android Studio中返回Null